Post Reply 
HP48G soft menu toggle: How?
07-23-2023, 02:11 AM
Post: #1
HP48G soft menu toggle: How?
I want to write a program that has the option for SI or English units. Some soft menus on the 48G have a small square that will appear and disappear allowing one to do exactly what I want. To know which units should be used.

A good example of what I am talking about is the menu under the Equation Library (Right Shift 3). SI or ENGL may have the square depending on which the user has selected.

Anyone know how to use this feature? I am assuming I can use it with TMENU. Lots of assumptions on my part.

TIA

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-23-2023, 12:13 PM
Post: #2
RE: HP48G soft menu toggle: How?
Example attached.


Attached File(s) Thumbnail(s)
   

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-23-2023, 12:33 PM
Post: #3
RE: HP48G soft menu toggle: How?
The sysRPL entry called MakeBoxLabel at #2E189 (on the 50g) makes a label with a box inside. It takes a string as argument and returns a GROB of the menu label.
Find all posts by this user
Quote this message in a reply
07-23-2023, 05:56 PM
Post: #4
RE: HP48G soft menu toggle: How?
(07-23-2023 12:33 PM)David Hayden Wrote:  The sysRPL entry called MakeBoxLabel at #2E189 (on the 50g) makes a label with a box inside. It takes a string as argument and returns a GROB of the menu label.

David, thank you for the information. That led me down a path where I may have something for the 48G.

3A399 BoxLabelGrob 21x8 Box ("Flagged" menu key)

Does anyone have any experience with using a Flagged soft menu key in a userRPL program?

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-23-2023, 08:42 PM
Post: #5
RE: HP48G soft menu toggle: How?
It's possible to create 'toggled' menu items using nothing more than userRPL.

Page 189 of Bill Wickes' "HP48 Insights", vol. 1. has an example of how to use a graphic for the menu item - so all you need to do is create 2 grobs of the right size, one with the toggle 'on' and the other 'off' and have the key action swap the menu over to the alternate display before doing whatever it is that needs to be done.

You can download the book here - https://literature.hpcalc.org/items/1571
Find all posts by this user
Quote this message in a reply
07-23-2023, 10:09 PM (This post was last modified: 07-23-2023 10:12 PM by johnb.)
Post: #6
RE: HP48G soft menu toggle: How?
There's also a block character in "chars" (right-shift PRG).

I've built self-referential functions that move the character from menu item to menu item as an indicator. For example, in the menu below, it moves it between Hex, Dec, Oct, and Bin. Ignore all the other menu items here (it's a general purpose / 16c set of menus). I'm showing the exact code so you can see how it might be used in practice. This is function SETB:

Code:
«
{ S→U  U→S  BDISP STWS RCWS 
   { "»FMT" SETF }
   { "HEX" « HEX SETB » }
   { "DEC" « DEC SETB » }
   { "OCT" « OCT SETB » }
   { "BIN" « BIN SETB » }
R→B  B→R  }
IF 'CSMNU' VTYPE -1 ≠ THEN CSMNU + END
DUP BASEN 6 +
GET DUP 1 GET "▀" + 1 
SWAP PUT BASEN ^ +
SWAP PUT MENU 1.02 MENU
»

The first bit (between the external set of braces {}) is the menu.

The first row of button assignments are just signed/unsigned conversions, a function that shows 'x' in all 4 major bases, set/recall word size, and "switch to format menu. Ignore this part.

The CSMNU stuff adds on additional rows to the menu shown, and can also be safely ignored.

The interesting part are the Hex/Dec/Oct/Bin buttons (which fall on the next page of the softbutton menu), and their assigned function calls. The bottom few steps of the program get the 3-character name, append the block character, assign it as the button label while assigning the default labels to the rest, and install it all as a menu. Every time you press one of the hotkeys assigned to Hex/Dec/Oct/Bin, SETB edits the menu and replaces it in place.

Hope this helps!

Daily drivers: 15c, 32sII, 35s, 41cx, 48g, WP 34s/31s. Favorite: 16c.
Latest: 15ce, 48s, 50g. Gateway drug: 28s found in yard sale ~2009.
Find all posts by this user
Quote this message in a reply
07-24-2023, 02:11 AM
Post: #7
RE: HP48G soft menu toggle: How?
Thank you both for the new information.

How do I go about creating a Grob that looks identical to a soft menu with text and the square using an HP48G? Anything out there that describes this process specifically for soft menu images? Using the Grob seems like the easiest method but I will probably try both to get a feel for both.

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-24-2023, 04:43 AM
Post: #8
RE: HP48G soft menu toggle: How?
(07-24-2023 02:11 AM)DM48 Wrote:  How do I go about creating a Grob that looks identical to a soft menu with text and the square using an HP48G? Anything out there that describes this process specifically for soft menu images? Using the Grob seems like the easiest method but I will probably try both to get a feel for both.

Put the desired string on the stack, then do this:
-- For a standard label (no box): #3A328h SYSEVAL
-- For a label with a box: #3A38Ah SYSEVAL
This creates the desired GROB. Place it at the beginning of a menu item list as per the manual.

Example: Do all of the following:
"NO" #3A328h SYSEVAL
"YES" #3A38Ah SYSEVAL
2 →LIST TMENU
... and see [ NO ] [YES box] in the soft menu area.
N.B. These SYSEVAL addresses only work on the 48G Series.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-25-2023, 01:31 AM
Post: #9
RE: HP48G soft menu toggle: How?
Joe, thank you kind sir. I just ran some tests on my 48G and it’s perfect. I’ve not really used GROBs in a program before so now I have to figure out how I want to handle this tiny program I have written for me and my son.

I have four soft menu keys for the kinematic equations.

t->d
d->t
t->Vf
Vf->t


I want to have a SI and ENGL option for units. Do most people toggle the soft menu and just change a state of a flag (20 for example)? And use CASE statements from there? Just high level thinking here.

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-25-2023, 05:58 AM (This post was last modified: 07-25-2023 06:00 AM by Joe Horn.)
Post: #10
RE: HP48G soft menu toggle: How?
(07-25-2023 01:31 AM)DM48 Wrote:  I want to have a SI and ENGL option for units. Do most people toggle the soft menu and just change a state of a flag (20 for example)? And use CASE statements from there? Just high level thinking here.

Perhaps you can you use the built-in SI / ENGL toggler for this: Press right-shift 3 and see them on the F1 and F2 keys. They control flag 60 (clear = SI, set = ENGL), so your programs can test flag 60 (that's positive 60, a "user flag") to see which mode is set. This would obviate the need to program your own mode-switching softkey.

EDIT -- Oops, I just noticed that you mentioned this in your original post. Sorry if I'm misunderstanding your programming goal.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-25-2023, 04:57 PM
Post: #11
RE: HP48G soft menu toggle: How?
(07-25-2023 05:58 AM)Joe Horn Wrote:  
(07-25-2023 01:31 AM)DM48 Wrote:  I want to have a SI and ENGL option for units. Do most people toggle the soft menu and just change a state of a flag (20 for example)? And use CASE statements from there? Just high level thinking here.

Perhaps you can you use the built-in SI / ENGL toggler for this: Press right-shift 3 and see them on the F1 and F2 keys. They control flag 60 (clear = SI, set = ENGL), so your programs can test flag 60 (that's positive 60, a "user flag") to see which mode is set. This would obviate the need to program your own mode-switching softkey.

EDIT -- Oops, I just noticed that you mentioned this in your original post. Sorry if I'm misunderstanding your programming goal.

Joe, you filled in a big gap for me with the Flag 60 information. I didn't realize the SI and ENGL were calculator wide. For some reason, I just assumed it was contained to the EQ LIB. Thank you sir.

I am making our own little Kinematic program to teach my son (young) how to write programs. We are progressing to the point of using units and we thought it would be nice to have the SI and ENGL toggle on the soft menu.

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
07-26-2023, 11:04 PM
Post: #12
RE: HP48G soft menu toggle: How?
(07-25-2023 05:58 AM)Joe Horn Wrote:  Perhaps you can you use the built-in SI / ENGL toggler for this: Press right-shift 3 and see them on the F1 and F2 keys. They control flag 60 (clear = SI, set = ENGL), so your programs can test flag 60 (that's positive 60, a "user flag") to see which mode is set.

thanks Joe, I didn't know that either, and pleased to see it carried forward to the 50g too.

Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 17B/II/II+ 28S 42S/DM42 32SII 48GX 50g 35s WP34S PrimeG2 WP43S/pilot/C47
Casio, Rockwell 18R
Find all posts by this user
Quote this message in a reply
07-27-2023, 03:41 PM
Post: #13
RE: HP48G soft menu toggle: How?
There are several ways to approach this. If you want to use the same "flag 60" mechanism that the Equation Library uses, something like the following might work if you need a custom menu and don't want to use the pre-existing one that comes with the Equation Library:

Code:
SETMENU
\<<
  @ Place the MakeStdLabel and MakeBoxLabel SYSEVAL codes on the stack
  #3A328h #3A38Ah

  @ If flag 60 is set, SWAP the two SYSEVAL codes
  60 FS? ::SWAP IFT

  @ Create the appropriate GROB for SI
  "SI" SWAP SYSEVAL

  @ Append the code to be run when SI is pressed
  \<< 60 CF SETMENU \>> 2 \->LIST

  @ Create the appropriate GROB for ENGL
  "ENGL" ROT SYSEVAL

  @ Append the code to be run when ENGL is pressed
  \<< 60 SF SETMENU \>> 2 \->LIST

  @ Build the menu definition list and activate it
  2 \->LIST TMENU
\>>

The above requires that the program is named "SETMENU", but that could be changed by updating the program references in the menu item assignments in the code.
Find all posts by this user
Quote this message in a reply
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 \>>


[Image: rMtrw0h.png]

[ 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:
  • you have installed the Equation Library Card (be it version A or B);
  • and you have changed the following part:

    # E301Dh LIBEVAL

    to:

    # 111020h ELSYSEVAL
    (that’s right, not SYSEVAL, nor LIBEVAL, but ELSYSEVAL).
Find all posts by this user
Quote this message in a reply
08-01-2023, 12:14 AM
Post: #15
RE: HP48G soft menu toggle: How?
(07-24-2023 04:43 AM)Joe Horn Wrote:  Put the desired string on the stack, then do this:
-- For a standard label (no box): #3A328h SYSEVAL
-- For a label with a box: #3A38Ah SYSEVAL
This creates the desired GROB. Place it at the beginning of a menu item list as per the manual.

Example: Do all of the following:
"NO" #3A328h SYSEVAL
"YES" #3A38Ah SYSEVAL
2 →LIST TMENU
... and see [ NO ] [YES box] in the soft menu area.
N.B. These SYSEVAL addresses only work on the 48G Series.

Not true, these are supported entry points, respectively labelled MakeStdLabel (#3A328h) and MakeBoxLabel (#3A38Ah), which work on *any* HP-48, from ROM revision A to R.
Find all posts by this user
Quote this message in a reply
08-01-2023, 04:47 AM
Post: #16
RE: HP48G soft menu toggle: How?
(08-01-2023 12:14 AM)Giuseppe Donnini Wrote:  
(07-24-2023 04:43 AM)Joe Horn Wrote:  Put the desired string on the stack, then do this:
-- For a standard label (no box): #3A328h SYSEVAL
-- For a label with a box: #3A38Ah SYSEVAL
This creates the desired GROB. Place it at the beginning of a menu item list as per the manual.

Example: Do all of the following:
"NO" #3A328h SYSEVAL
"YES" #3A38Ah SYSEVAL
2 →LIST TMENU
... and see [ NO ] [YES box] in the soft menu area.
N.B. These SYSEVAL addresses only work on the 48G Series.

Not true, these are supported entry points, respectively labelled MakeStdLabel (#3A328h) and MakeBoxLabel (#3A38Ah), which work on *any* HP-48, from ROM revision A to R.

Oops! Quite right. Thank you! What I should have said is, "These SYSEVAL addresses only work on the 48 series, not the 49G, 49g+, or 50g."

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2023, 05:55 PM
Post: #17
RE: HP48G soft menu toggle: How?
(07-23-2023 08:42 PM)BruceH Wrote:  It's possible to create 'toggled' menu items using nothing more than userRPL.

Page 189 of Bill Wickes' "HP48 Insights", vol. 1. has an example of how to use a graphic for the menu item - so all you need to do is create 2 grobs of the right size, one with the toggle 'on' and the other 'off' and have the key action swap the menu over to the alternate display before doing whatever it is that needs to be done.

You can download the book here - https://literature.hpcalc.org/items/1571

Bruce, thank you for this tip and link. It has been very helpful.

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
10-01-2023, 06:24 PM
Post: #18
RE: HP48G soft menu toggle: How?
(07-23-2023 10:09 PM)johnb Wrote:  There's also a block character in "chars" (right-shift PRG).

I've built self-referential functions that move the character from menu item to menu item as an indicator. For example, in the menu below, it moves it between Hex, Dec, Oct, and Bin. Ignore all the other menu items here (it's a general purpose / 16c set of menus). I'm showing the exact code so you can see how it might be used in practice. This is function SETB:

Code:
«
{ S→U  U→S  BDISP STWS RCWS 
   { "»FMT" SETF }
   { "HEX" « HEX SETB » }
   { "DEC" « DEC SETB » }
   { "OCT" « OCT SETB » }
   { "BIN" « BIN SETB » }
R→B  B→R  }
IF 'CSMNU' VTYPE -1 ≠ THEN CSMNU + END
DUP BASEN 6 +
GET DUP 1 GET "▀" + 1 
SWAP PUT BASEN ^ +
SWAP PUT MENU 1.02 MENU
»

The first bit (between the external set of braces {}) is the menu.

The first row of button assignments are just signed/unsigned conversions, a function that shows 'x' in all 4 major bases, set/recall word size, and "switch to format menu. Ignore this part.

The CSMNU stuff adds on additional rows to the menu shown, and can also be safely ignored.

The interesting part are the Hex/Dec/Oct/Bin buttons (which fall on the next page of the softbutton menu), and their assigned function calls. The bottom few steps of the program get the 3-character name, append the block character, assign it as the button label while assigning the default labels to the rest, and install it all as a menu. Every time you press one of the hotkeys assigned to Hex/Dec/Oct/Bin, SETB edits the menu and replaces it in place.

Hope this helps!

John, do you have a much simpler (less of it) program that can show how this works in practice?

Does this method rely on having other menus already created?

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
10-01-2023, 09:39 PM (This post was last modified: 10-01-2023 09:41 PM by DM48.)
Post: #19
RE: HP48G soft menu toggle: How?
A tangent to my above. I am trying to write a simple program that will test of FLAG 20 is set, if yes then put the FLAG on the softmenu, if not, don't put the flag on the soft menu.

It seems to work at startup without issue. What is a good way to arrange the code so it would refresh upon a change while running? I am unsure how to handle this.

I hope this makes sense. My program below. I just typed the code from my calculator so it may not be formatted exactly but I think you will understand it.

Program stored as:

'XX'

Code:
 \<< "T->D"

IF 20 FS? 1 = 
THEN # 3A328h
SYSEVAL

ELSE # 3A38Ah
SYSEVAL
END

\<< 2  *  \>> 2 ->LIST {}
{"SF 20" \<< 20 SF \>> } 
{ "CF 20" \<< 20 CF \>> } 
{ "XX" \<< CLLCD \>> }

{"CANCEL" <<\ 2 MENU \>> } 

6 ->LIST TMENU  \>>


Attached File(s) Thumbnail(s)
   

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
10-02-2023, 09:00 PM
Post: #20
RE: HP48G soft menu toggle: How?
Maybe a more specific question would be better. Once I press the soft-key and the flag status is changed, how do I refresh the soft-key menu to reflect the change?

HP48GX, HP42s and DM42.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 8 Guest(s)