Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multiple Undo Program / Command Logger

21 views
Skip to first unread message

ryan.edwards

unread,
May 3, 2007, 5:30:30 AM5/3/07
to
I recently came across this program that John H. Meyers posted last
October which provides for near unlimited levels of undo on the
HP49/50.

:: DEPTH #0=?SEMI DROP ' xHALT EvalNoCK ROMPTR A3 10 ;

When that is stored as \GbENTER (Beta) it works very nicely. I mapped
CONT to the HIST button on my 50g and KILL to the UNDO button to give
me quick control over the levels of undo.

The only problem occurs when I try to do anything not on the stack.
Operations like the Matrixwriter, the Equation Writer, forms like the
Mode menu or flags browser do not like it when the program attempts to
HALT whenever I hit the ENTER key.

The easy fix for this of course is to clear flag -63 to disable the
vectored enter when using these, but that is tedious to do manually.
Initially, I tried decompiling the code called by the MTRW and EQW
keys so I could modify it to add a flag disable but that only works
for those operations. Anything else like the text editor, or Modes,
etc will not work without me doing a lot of decompiling and modifying
(if that's even possible or advisable!).

Does anybody have a suggestion to fix this? The best case would be to
have the vectored enter automatically on whenever I am at the stack
and automatically disabled (or otherwise ineffective) when I am not.
I'm only a beginner SysRPL programmer, so I don't really know all of
what this calculator can do.

Suggestions are welcomed!

Thanks,
Ryan

ryan.edwards

unread,
May 3, 2007, 5:35:13 AM5/3/07
to

Andreas Möller

unread,
May 3, 2007, 12:48:50 PM5/3/07
to
On 3 Mai, 11:30, "ryan.edwards" <ryan.edwa...@shaw.ca> wrote:
> I recently came across this program that John H. Meyers posted last
> October which provides for near unlimited levels of undo on the
> HP49/50.
>
> :: DEPTH #0=?SEMI DROP ' xHALT EvalNoCK ROMPTR A3 10 ;
>
> When that is stored as \GbENTER (Beta) it works very nicely. I mapped
> CONT to the HIST button on my 50g and KILL to the UNDO button to give
> me quick control over the levels of undo.
>
> The only problem occurs when I try to do anything not on the stack.
> Operations like the Matrixwriter, the Equation Writer, forms like the
> Mode menu or flags browser do not like it when the program attempts to
> HALT whenever I hit the ENTER key.
These programs use a technique called Parametrized Outer Loop or
called POL abbreviated.
Suspending of a running POL is controlled by a flag, the SuspendOK?
parameter-flag.

> The easy fix for this of course is to clear flag -63 to disable the
> vectored enter when using these, but that is tedious to do manually.
> Initially, I tried decompiling the code called by the MTRW and EQW
> keys so I could modify it to add a flag disable but that only works
> for those operations. Anything else like the text editor, or Modes,
> etc will not work without me doing a lot of decompiling and modifying
> (if that's even possible or advisable!).

No need to decompile the code in this case.

> Does anybody have a suggestion to fix this? The best case would be to
> have the vectored enter automatically on whenever I am at the stack
> and automatically disabled (or otherwise ineffective) when I am not.
> I'm only a beginner SysRPL programmer, so I don't really know all of
> what this calculator can do.

Just check the POL-Flags in front of your program and depending on the
status of them your program is run or not. With these two flags you
should be able to accomplish your task:

AppMode? ( -> flag Is currently a POL active? )
( TRUE -> a POL is active | FALSE -> no POL is
active )

SuspendOK? ( -> flag Does the current user interface allow
suspension? )
( TRUE -> Suspend allowed | FALSE -> Suspend NOT
allowed )

Greetings
Andreas
http://www.software49g.gmxhome.de


ryan.edwards

unread,
May 5, 2007, 5:36:41 AM5/5/07
to
> These programs use a technique called Parametrized Outer Loop or
> called POL abbreviated.
> Suspending of a running POL is controlled by a flag, the SuspendOK?
> parameter-flag.
>
> Just check the POL-Flags in front of your program and depending on the
> status of them your program is run or not. With these two flags you
> should be able to accomplish your task:
>
> AppMode? ( -> flag Is currently a POL active? )
> ( TRUE -> a POL is active | FALSE -> no POL is
> active )
>
> SuspendOK? ( -> flag Does the current user interface allow
> suspension? )
> ( TRUE -> Suspend allowed | FALSE -> Suspend NOT
> allowed )

Thanks for your help Andreas!

I did some reading up on this topic and fiddled and fiddled and I now
I think I have a very nice unlimited stack undo that seems to work
flawlessly so far.

For anybody who may be interested in using this themselves here is the
code I ended up with. I would welcome any comments/suggestions
regarding improvements. As I said, I'm but a novice grasshopper SysRPL
programmer.

::
DEPTH
#0=?SEMI
DROP
AppMode?
?SEMI
::
SuspendOK?
NOT?SEMI
::
'


xHALT
EvalNoCK
ROMPTR A3 10
;

;
;

That does it. Assign CONT to HIST button and KILL to UNDO. And
everything works very nicely, both in and out of menus/apps, and the
stack.

Ryan


John H Meyers

unread,
May 5, 2007, 7:43:13 PM5/5/07
to
[about a multi-level UNDO, originally in old thread]
http://groups.google.com/group/comp.sys.hp48/browse_thread/thread/c5425fbaa74b8f8

On Thu, 03 May 2007 11:48:50 -0500, Andreas Möller wrote:

> AppMode? ( -> flag Currently a POL active? )
> SuspendOK? ( -> flag Current user interface allows suspend? )

On Sat, 05 May 2007 04:36:41 -0500, ryan.edwards wrote:

[a program using the above]

Excellent improved program!

You don't need "inner" secondaries after ?SEMI,
so you can shorten to:

"
:: DEPTH #0=?SEMI DROP


AppMode? ?SEMI SuspendOK? NOT?SEMI
' xHALT EvalNoCK ROMPTR A3 10 ;

@" -92 SF ASM2 '\GbENTER' STO

Note: On HP48G[X/+] use ROMPTR A3 E instead.

> That does it. Assign CONT to HIST button and KILL to UNDO.

Or perhaps CONT to UNDO? (for original behavior of UNDO,
except now multi-level when flags -62 and -63 are set)

> And everything works very nicely, both in and out of menus/apps,
> and the stack.
>
> Ryan

Nice work!

[r->] [OFF]

John H Meyers

unread,
May 6, 2007, 1:18:32 PM5/6/07
to
On Sat, 05 May 2007 18:43:13 -0500:

[about a kind of "push" and "pop" for "Last Stacks,"
allowing multi-level UNDO]

Flags -62 and -63 must both be set
for the following automatic programs to work.

> AppMode? ?SEMI SuspendOK? NOT?SEMI ' xHALT ...

It appears that "AppMode? ?SEMI" can also be omitted,
since HALT itself is concerned only with SuspendOK?

HALT errors if suspending isn't OK, which is the problem
that Ryan Edwards had encountered with the original version
at the start of this thread (and subsequently solved).

So the bare remaining essentials are (in SysRPL):

"
:: DEPTH #0=?SEMI DROP SuspendOK? NOT?SEMI


' xHALT EvalNoCK ROMPTR A3 10 ;

@" -92 SF ASM2 '\GbENTER' STO @ Beta is Alpha RS "B"

The first ?SEMI above protects against manual execution
with an empty stack, the second ?SEMI protects against
trying to HALT when HALT is not allowed; if allowed,
it then halts (which creates a brand new "Last Stack")
ready to later resume and UNDO the original stack
upon execution of CONT. If keyboard UNDO is attempted
instead, it tries to undo the *new* "Last Stack,"
which tends to have no effect when BetaENTER (or HALT)
keeps starting a fresh new "Last Stack" each time.

Note:
On HP48G[X/+] use ROMPTR A3 E in place of ROMPTR A3 10

FWIW, you can have a different BetaENTER program
in every directory, so you can make different directories
for using different useful BetaENTER programs for different purposes
(any directory not having its own BetaENTER program
will look to higher directories to search for one).

Whenever the following (for all HP48/49/50)
performs an algebraic RPN function from the keyboard,
it first leaves on the stack
a list of the original args and function, then the result,
so it resembles what ALG mode does, but for RPN:

\<< DEPTH \-> d \<< LASTARG DEPTH d - \->LIST
"{1 " ROT + STR\-> DUP SIZE GET
DUP TYPE 18 == { + SWAP } { DROP2 } IFTE
-55 DUP SF CF \>> \>> '\GbENTER' STO

E.g. 2 3 + ==> { 2 3 + } and 5

To re-evaluate any list from above, you could use
\<< DUP EVAL \>> 'REDO' STO

The following, with flag -3 clear,
builds an algebraic expression using RPN operations;
use DUP EVAL [or REDO] to get a final numeric result:

@ HP50G/49G[+]/48Gii only
@ (needs 256 ATTACH before entering or transferring)
\<< DEPTH \-> d \<< LASTARG DEPTH d - \->LIST
"{1 " ROT + STR\-> DUP SIZE GET DUP TYPE 18 == {
+ OVER TYPE 9 == { DROP } { NIP \->ALG } IFTE
} { DROP2 } IFTE -55 DUP SF CF \>> \>> '\GbENTER' STO

The next version extends the above by *automatically*
showing the numeric result at every step:

@ HP50G/49G[+]/48Gii only
@ (needs 256 ATTACH before entering or transferring)
\<< DEPTH \-> d \<< LASTARG DEPTH d - \->LIST
"{1 " ROT + STR\-> DUP SIZE GET IF DUP TYPE 18 == THEN
+ NIP 1 \<< DUP TYPE 5 == { HEAD } IFT \>> DOLIST
DUP LIST\-> DROP EVAL -79 CF -97 SF
DUP TYPE 9 == { NIP } { DROP \->ALG } IFTE
IFERR DUP \->NUM THEN DROP ELSE 2 \->LIST END
ELSE DROP2 END -55 DUP SF CF \>> \>> '\GbENTER' STO

Does the above resemble this TI "RPN interface"?
http://www.paxm.org/symbulator/download/rpn.html

The following resets flags and modes after any operation,
thus undoing forced mode changes for CAS commands
(though it can't restore deleted variables, if any);
you should first set your preferred modes and do one PUSH
(turning off USER mode while you do this),
so that there will be something to POP the very first time:

\<< PATH POP PUSH EVAL { -62 -63 -120 } SF
DEPTH { DROP } IFT -55 DUP SF CF \>> '\GbENTER' STO

Faster replacement for the combination of POP and PUSH:
\<< { HOME CASDIR ENVSTACK } RCL DUP SIZE
{ HEAD LIST\-> 1 - SWAP EVAL \->LIST STOF }
{ DROP PUSH } IFTE \>> 'POPU' STO

Replace SWAP EVAL in the above with NIP
to avoid restoring the current directory,
thus allowing POPU to replace PATH POP PUSH EVAL
(restore flags only, allowing UPDIR
and/or entering a subdirectory).

Other uses of BetaENTER could be to automatically display
level-1 (if numeric) as degrees+minutes+seconds,
or in some other special format,
or to automatically simplify any algebraic results,
or to automatically do all sorts of other stuff
(but can it slice bread?)

[r->] [OFF]

John H Meyers

unread,
May 6, 2007, 2:12:56 PM5/6/07
to
On Sun, 06 May 2007 12:18:32 -0500:

> Whenever the following (for all HP48/49/50)
> performs an algebraic RPN function from the keyboard,
> it first leaves on the stack
> a list of the original args and function, then the result,
> so it resembles what ALG mode does, but for RPN:
>
> \<< DEPTH \-> d \<< LASTARG DEPTH d - \->LIST
> "{1 " ROT + STR\-> DUP SIZE GET
> DUP TYPE 18 == { + SWAP } { DROP2 } IFTE
> -55 DUP SF CF \>> \>> '\GbENTER' STO
>
> E.g. 2 3 + ==> { 2 3 + } and 5

To include CAS functions (and advanced 48G functions),
change that to:

\<< DEPTH \-> d \<< LASTARG DEPTH d - \->LIST

"{1 " ROT + STR\-> DUP SIZE GET { 14. 18. }
OVER TYPE POS { + SWAP } { DROP2 } IFTE


-55 DUP SF CF \>> \>> '\GbENTER' STO

> To re-evaluate any list from above, you could use
> \<< DUP EVAL \>> 'REDO' STO

I should have used that to re-do the original post :)

[r->] [OFF]

0 new messages