HP48G soft menu toggle: How?
|
08-01-2023, 12:07 AM
(This post was last modified: 08-01-2023 09:36 AM by Giuseppe Donnini.)
Post: #14
|
|||
|
|||
RE: HP48G soft menu toggle: How?
If your goal is to use a menu just like the one in the Equation Library, the shortest and most elegant solution is to reuse just that — the Equation Library’s top menu. Luckily, this can be done even without resorting to System RPL. If we take a closer look at the library containing the Equation Library, which is library 227, or, in System RPL parlance, ROMPART #E3h, we find that command number 29, or ROM-WORD #1Dh — labelled ELTopMenu by HP (for “Equation Library Top Menu”) —, contains the desired menu almost ready for use. The only thing that needs to be addressed is the presence of excess softkeys which we don’t want to include in our custom menu, and which, moreover, might bring about disaster, if used outside of the Equation Library’s own environment. So let’s examine the menu definition in question (I’ve added some comments to make it as readable as possible for non-system programmers):
NULLNAME ELTopMenu ( Resolution of ROMPTR 0E3 01D ) { { ( ========= 1ST SOFTKEY ========= ) :: ( --------- LABEL --------- ) TakeOver ( *We take over [part of] the label building* ) $ "SI" ( *Label String* ) SIXTY TestUserFlag ( *Test Units Type Flag* ) NOT Box/StdLabel ( *If clear [SI], create a label with a bullet* ) ; :: ( --------- KEY OBJECT --------- ) TakeOver ( *Escape default interpretation by the system* ) SIXTY ClrUserFlag ( *Clear Units Type Flag* ) DispMenu ( *Redisplay menu to update all affected labels* ) ; } { ( ========= 2ND SOFTKEY ========= ) :: ( --------- LABEL --------- ) TakeOver ( *We take over [part of] the label building* ) $ "ENGL" ( *Label String* ) SIXTY TestUserFlag ( *Test Units Type Flag* ) Box/StdLabel ( *If set [ENGL], create a label with a bullet* ) ; :: ( --------- KEY OBJECT --------- ) TakeOver ( *Escape default interpretation by the system* ) SIXTY SetUserFlag ( *Set Units Type Flag* ) DispMenu ( *Redisplay menu to update all affected labels* ) ; } { ( ========= 3RD SOFTKEY ========= ) :: ( --------- LABEL --------- ) TakeOver ( *We take over [part of] the label building* ) $ "UNITS" ( *Label String* ) SIXTYONE TestUserFlag ( *Test Units Usage Flag* ) NOT Box/StdLabel ( *If clear [YES], create a label with a bullet* ) ; :: ( --------- KEY OBJECT --------- ) TakeOver ( *Escape default interpretation by the system* ) SIXTYONE DUP UserITE ( *Toggle Units Usage Flag* ) ClrUserFlag SetUserFlag DispMenu ( *Redisplay the menu to update the label* ) ; } NullMenuKey ( ========= 4TH SOFTKEY ========= ) NullMenuKey ( ========= 5TH SOFTKEY ========= ) { ( ========= 6TH SOFTKEY ========= ) $ "QUIT" ( --------- LABEL --------- ) :: ( --------- KEY OBJECT --------- ) TakeOver ( *Escape default interpretation by the system* ) ELquit ( [ROMPTR 0E3 01F] *Quit Equation Library* ) ; } } [ Note that, with the exception of ELquit, only supported entry points are being used. ] As is readily apparent from the menu definition, we only need at most the first three softkeys. The fourth and fifth would actually be harmless, but we would rather want to use that space for our own softkey definitions. On the other hand, the last softkey would be downright dangerous, as it acts upon temporary variables that only exist inside the Outer Loop of the Equation Library. In summary, all we have to do is to put the list containing the menu definition on the stack and to cut off its last three (or four) elements containing the softkey definitions we don’t need or want — which is as simple as this: \<< # E301Dh LIBEVAL 1 2 SUB \>> Or, if we want to keep the third softkey, too, which controls the Units Usage Flag (+61) used by the Constants Library, the Multiple Equation Solver, and the (optional) Periodic Table: \<< # E301Dh LIBEVAL 1 3 SUB \>> The result can easily be combined with your own menu by simply joining the appropriate lists. For instance, if your menu consists of two softkeys defined respectively by the global names P1 and P2 (referencing perhaps two user-written programs), you could execute the following program to place the extracted units softkeys at the end of the menu page: \<< { P1 P2 {} } # E301Dh LIBEVAL 1 3 SUB + TMENU \>> [ WARNING: You should never directly edit a menu containing parts in System RPL, because, at the User RPL level, neither the decompiler nor the parser know how to handle those parts correctly. ] The method described above works even on the HP-48SX, provided that:
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)