HP-49G+ - Where is the "last x" key / function?



#7

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


#8

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.

#9

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

#10

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

Regards, Miguel


#11

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.


#12

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

Regards, Miguel


#13

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

#14

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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP50g: Writing a function that returns a function Chris de Castro 2 257 12-10-2013, 06:49 PM
Last Post: Han
  IFERR function on HP Prime Mic 2 230 12-02-2013, 01:33 AM
Last Post: cyrille de Brébisson
  HP Prime: Dirichlet's eta function recognized but not numerically evaluated Helge Gabert 0 137 11-16-2013, 03:41 PM
Last Post: Helge Gabert
  Possible bug with sqrt function in the HP prime Michael de Estrada 6 317 11-15-2013, 12:49 PM
Last Post: Michael de Estrada
  HP-41 MCODE: The Last Function - at last! Ángel Martin 0 147 11-08-2013, 05:11 AM
Last Post: Ángel Martin
  HP Prime - EEX/X/Toolbox-key suggestions bluesun08 2 224 11-07-2013, 06:15 PM
Last Post: bluesun08
  HP PRIME : strange behavior when trying user key capability Damien 12 568 11-03-2013, 11:02 AM
Last Post: Joe Horn
  HP Prime 'where' function bluesun08 11 541 10-29-2013, 06:56 PM
Last Post: Joe Horn
  HP PRIME: How to use [a b/c] key from a program Joseph Ec 4 263 10-29-2013, 06:18 PM
Last Post: Joseph Ec
  HP Prime - Defining a function bluesun08 5 300 10-23-2013, 02:43 PM
Last Post: Han

Forum Jump: