The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

HP-49G+ - Where is the "last x" key / function?
Message #1 Posted by Miguel on 25 Oct 2005, 12:49 p.m.

Dear friends, I´ve just got a new 49G+ and realized it does not have the "last x" key / function. Is it true?

Regards, Miguel

      
Re: HP-49G+ - Where is the "last x" key / function?
Message #2 Posted by Jeff O. on 25 Oct 2005, 1:09 p.m.,
in response to message #1 by Miguel

You are correct, there is no "Last X" key or function that replicates or closely mimics that function of the RPN calculators. You have to write a program to mimic the functionality. I have one which I am pretty sure was posted here (or perhaps at comp.sy.hp48) by James M. Prange. If you search the archives, you might find more information. The program I use is as follows:

<< DEPTH -> n
  << LASTARG DEPTH n - DUP -> s
    << ROLLD s 1 - DROPN DUP DROP
    >>
  >>
>>

Type the above in, and save to a variable named “LAST x”. The program seems to work fine.
            
Re: HP-49G+ - Where is the "last x" key / function?
Message #3 Posted by Miguel on 25 Oct 2005, 1:20 p.m.,
in response to message #2 by Jeff O.

Dear Jeff, thank you very much for the program. I´ll try it right now! Regards, Miguel

            
Re: HP-49G+ - Where is the "last x" key / function?
Message #4 Posted by Miguel on 25 Oct 2005, 1:31 p.m.,
in response to message #2 by Jeff O.

Dear Jeff, I was thinking a litle more: why not use the "lastarg" function only, assigned to some key?

Regards, Miguel

                  
Re: HP-49G+ - Where is the "last x" key / function?
Message #5 Posted by Gene on 25 Oct 2005, 2:08 p.m.,
in response to message #4 by Miguel

LastARG returns the last arguments! That may be more than just one.

Example: In approximate mode, 25 ENTER 6 divide.

LASTX would return a "6".

LASTARG returns 25 to the second level of the stack and 6 to the first level of the stack.

                        
Re: HP-49G+ - Where is the "last x" key / function?
Message #6 Posted by Miguel on 25 Oct 2005, 2:21 p.m.,
in response to message #5 by Gene

Got it! Thank you! The program works, but for "33 alpha 'a1' sto>" , it returns a1.

Regards, Miguel

                              
Re: HP-49G+ - Where is the "last x" key / function?
Message #7 Posted by Gene on 25 Oct 2005, 3:57 p.m.,
in response to message #6 by Miguel

That's because when you do ... 'a1' STORE the 'a1' is the last argument in the first level of the stack.

It is the "lastx".

Gene

            
Re: HP-49G+ - Where is the "last x" key / function?
Message #8 Posted by James M. Prange (Michigan) on 25 Oct 2005, 11:00 p.m.,
in response to message #2 by Jeff O.

Thanks for the credit, Jeff. I may well have posted that program somewhere, sometime, but it's not my preferred version. My only problem with it is in the case of an empty last arguments buffer, it errors out instead of returning 0.

Here are three programs that handle the empty last arguments buffer case better.

Note that in the programs, I'm using exact integers (type 28) for the 49 series. "Real" numbers (type 0) also work, but of course the results from the BYTES command will be different.

This first one both returns 0. (as a real number) to the stack and leaves it in the buffer if the last arguments buffer was empty.

%%HP: T(3)A(D)F(.);
@ Download (or enter) in exact mode on 49 series.
@ Results from the BYTES command:
@ 49 series checksum: # 2C67h
@ 49 series size:         69.
@ 48 series checksum: # ECA9h
@ 48 series size:          69
\<<
  DEPTH \-> d
  \<<
    LASTARG DEPTH d -
    IF
      DUP
    THEN
      DUP2 2 + ROLLD DROPN
    END
    DUP DROP
  \>>
\>>
This second one returns 0. (as a real number) to the stack and leaves the buffer empty if the last arguments buffer was empty:
%%HP: T(3)A(D)F(.);
@ Download (or enter) in exact mode on 49 series.
@ Results from the BYTES command:
@ 49 series checksum: # B2D2h
@ 49 series size:        90.5
@ 48 series checksum:  # F5Dh
@ 48 series size:        94.5
\<<
  DEPTH \-> d
  \<< LASTARG DEPTH d -
    IF
      DUP
    THEN
      DUP2 2 + ROLLD DROPN DUP DROP
    ELSE
      -55 DUP SF CF
    END
  \>>
\>>
This last one doesn't return anything to the stack and leaves the buffer empty if the last arguments buffer was empty.
%%HP: T(3)A(D)F(.);
@ Download (or enter) in exact mode on 49 series.
@ Results from the BYTES command:
@ 49 series checksum: # 8C85h
@ 49 series size:         93.
@ 48 series checksum: # D527h
@ 48 series size:          97
\<<
  DEPTH \-> d
  \<< LASTARG DEPTH d -
    IF
      DUP
    THEN
      DUP2 2 + ROLLD DROPN DUP DROP
    ELSE
      DROP -55 DUP SF CF
    END
  \>>
\>>
If system flag -55 is set (No last args), then these programs will error out.

Note that after some commands that don't take any arguments, like CLEAR, DROP, and MEM, these programs don't return what was the last object in level 1.

In the 49 series, LASTARG is invoked by LeftShift ANS (over the ENTER key), at least in RPN mode. I've never used ALG mode, so won't offer any advice for that.

For similar programs for the 28 series, change LASTARG to LAST, and (in the last two programs) change -55 DUP SF CF to 31 DUP CF SF.

Even in the 48 and 49 series, LAST can be used as a synonym for LASTARG, to maintain backwards compatibility.

Personally, I prefer the first program that I've posted here best.

Just out of curiosity, which one do users of "Real RPN" models prefer?

Regards,
James

Edited: 25 Oct 2005, 11:04 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall