HP Forums

Full Version: HP-49G+ - Where is the "last x" key / function?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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

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.

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

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

Regards, 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.

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

Regards, 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

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.