XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ExtUsrRPL XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Programming on the HP49 in Extended User RPL A small but efficient tool for people familiar with UsrRPL who want to expand their programming possibilities without first learning SysRPL, a very rich but only poorly documented programming language for the HP48/49 operating system. This library tries to build a bridge from UsrRPL to SysRPL. The expansion of UsrRPL is minimal - one has only to learn to handle the quoter - the profit is enormous, however. ExtUsrRPL-programs can contain quite arbitrary objects, libraries, compressed strings, EXTERNALs, etc. More complex programs of this type are created in the interactive stack rather than in the editor. They can be written very compact. ExtUsrRPL-programs do not use the standard programm delimiters, in general, but are included in the SysRPL program delimiters, :: and ; (the semi). These delimiters can be seen with St~ from EURPL. Ordinary programs are shortened to equivalent EURPL-programs by processing them with ->XU (Example 1 below) which makes them smaller and faster, in general. In ExtUsrRPL, names and other objects can be quoted with the quoter ' (symbol Nr. 39) which prevents evaluation of the name or object following it. Using ' instead of the UsrRPL-quoters also saves bytes. However, byte saving is only a byproduct of '. Its main use is this: In UsrRPL, a list cannot "hold" a quoted name. A global name inside a list is always evaluated together with the list. That is prevented if putting ' in front of the name. This also holds for other list members: commands, for instance. This has the effect that a n y program can be created from a list, even if it is incorrect from the point of view of UsrRPL. Thus, error checking is not as strikt as in UsrRPL anymore. It's now in the programmer's responsability to avoid a crash, similar as in SysRPL. NEW in VERSION 5.2001: Text revised NEW in VERSION 4.2001: Command menu redesigned and text rewritten ----------------------------------- There are only six library commands. These are |3tog| |DAtog| |Stog| |->XU| |'R| |'| Their description below refers to the RPN-mode only. Let Alg, Prg, Lst, Meta denote any algebraic object, program, list, or (user) metaobject, resp. Here a metaobject is a collection of objects with a (real) count n in Level 1 and the objects in the Levels 2 through n+1. 3tog Toggles three representations of a program: its program, its metaobject and its list form. A test with some program on the stack will tell you more than lengthy explanation. The list form is convenient to modify a ExtUsrRPL program with stripped program delimiters, the metaobject form to modify a SysRPL-program or to form programs in the interactive stack. See Examples 2 below. Applied to algebraics, 3tog toggles its list, its program and its metaobject equivalents. Try this with '1+2=3' in both stack views (toggle with Stog). This tells you in detail what is meant. Stack-diagrams: Alg -> Prg -> Meta -> Lst -> Prg -> ... DAtog (Disassemble and Assemble toggler). Only for those who know some SysRPL and have loaded extable. Toggles a HP-object with its decompiled string representation. Based on ->S3 from lib 256 for decompiling and ASM2 from library 257 for recompiling. Both libs, 256 and 257, are automatically attached with EURPL in a warmstart. Stack-diagrams: Obj -> Str -> Obj St~ (Stackview-toggler). Toggles SysRPL stack view with normal stack view (flag -85). Some SysRPL objects are visible only in SysRPL stack view. ->XU (to "Xtended" UsrRPL). Strips recursively all closing name delimiters and program delimiters of a UsrRPL program - but not the delimiters of a local environement. ->XU also replaces the quoter from the library by an internal visible SysRPL-quoter. Similarly for lists. ->XU is very powerful. It expands, in a sense, the builtin compiler. Here its Stack diagram (mentioning only objects which are affected by ->XU): Prg -> Prg* or Lst -> Lst* or Quoter -> SysRPL-quoter 'R This and the next command are quoters. They don't take anything from the stack but look at the runstream instead. 'R quotes the object after the next semi, i.e., it's pushed on the stack and popped from the runstream. If there is no object after the next semi (e.g., if 'R is exectued from its key), the empty SysRPL program :: ; is pushed to the stack. ' The Quoter (Symbol 180). It is equivalent to the SysRPL quoter x' (ASCI symbol 39). The latter cannot normally be put on the stack or compiled from the editor with ENTER. Occurrences of ' in a program or in a list processed with ->XU will be replaced by the visible SysRPL quoter x'. This makes the program or list still shorter. Directly executed from its key, ' pushes the harmless SysRPL-command AtUserStack to the stack. ---------------------------------------------------------------------- EXAMPLE 1. The program << ' CASDIR >> quotes the name CASDIR. It has 25 bytes. Processed with ->XU transforms it into a program of only 17 bytes, without the user program delimiters and ' replaced by x' which is shown in the stack with or without the prefix x depending on the Stack-view flag. EXAMPLE 2. Put the library EXURPL on level 3, the real 2 on level 2 and the STO command on Level 1. Then go into the interactive stack (UpArrow) and make a list from these 3 objects. Next use 3tog to make a program from this list which doesn't have program delimiters and looks as: Library 303 EURPL 2. STO This is a small but typical ExtUsrRPL-program. Instead of installing the lib itself on my your 49, you may have run this program. Its execution stores the library automatically in port 2. EXAMPLE 3. The metaobject from of Example 1 (toggled with 3tog) is 5: << 5: x<< 4: ' 4: x' Normal Stack: 3: 'CASDIR' SysRPL-stack: 3: ID CASDIR 2: >> 2: x>> 1: 4. 1: %4 The program-delimiters are itself small programs. Both abort program execution if CANCEL was pressed during the program run. Now, << ' CASDIR >> runs so fast that it is unlikely that here the program-delimiters come ever into action. Thus, these delimiters are dispensable as they are in most other cases. EXAMPLE 4. Let's make a command, purge say, which does not operate like a RPN command but purges the name right after it. Thus, <> should purge the variable 'ABC'. This is very easily done with R'. Simply store the program << R' PURGE >> under 'purge' after stripping the program delimiters with ->XU. That's it. << purge 'ABC' >> is equivalent to << :: 'R PURGE ; 'ABC' >> and you see what happens: 'R first pushes the name 'ABC' to the stack (next object after the semi) and only then the RPN-command PURGE is executed. This kind of trickery allows the 49 to operate both in RPN and in algebraic mode. ---------------------------------------------------------------------- Wolfgang Rautenberg - raut@math.fu-berlin.de - www.math.fu-berlin.de/~raut