Having Trouble with User-Programmed Menus (Programming Query)

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Post Reply
J Peters
Posts: 10
Joined: Wed Apr 18, 2018 9:53 am

Having Trouble with User-Programmed Menus (Programming Query)

Post by J Peters »


I bought my DM42 nearly two years ago but am only just progressing to some of the more advanced programming techniques. Not enough time to play with it unfortunately.

I've used the term 'user' here to mean 'the person running a program I've written', even though this will usually be myself :D

I have read the HP42S manual about creating menu-driven programs. The process starts by you defining keys, giving each softkey a name and a target label. So far so good. My confusion starts when we reach the MENU statement. I would have expected this to cause the program to stop while it displays the pre-defined menu keys, but was surprised to find that program execution continues. You therefore have to add in a STOP command after the MENU command to allow the user time to press a softkey. Moreover you have to error-trap in case they press R/S to resume from STOP instead of a softkey.

Is this correct, or am I missing something? It seems rather over-complicated.

This leads me to a secondary question. If you DON'T put a STOP in the process, and allow program execution to continue whilst the menu is displayed, doesn't this allow the user to press a softkey and force a jump at any time? This strikes me as likely to cause all sorts of errors as the program flow could be disrupted with random results. Maybe not so bad if you had defined your keys to point to subroutines (XEQ) because these would return and resume, but I would have thought catastrophic if you've defined jumps with GTO.

Again, am I missing something? I don't see much point (and a lot of downside) to allowing the program to continue whilst simultaneously allowing a forced-jump at any time.

As a final question please, where is the EXITALL command? The manual introduces it as part of a program listing, but doesn't say how to key this in. I cannot find it on any of the menus.

Many thanks in advance.
Posts: 34
Joined: Sun Jul 09, 2017 1:03 am

Re: Having Trouble with User-Programmed Menus (Programming Query)

Post by Logan »

Sort of, you have the stop but then you would have something like a "GTO 00" immediately following it. So if the user pushes a menu key, it executes that label, comes back to your stop, steps down, and goes to LBL 00, refreshing the menu. You will always be looping back and recreating the menu, no matter whether the user pushes R/S or executes one of your menu keys.

If you didn't have the stop and the GTO to loop back, the program would continue to execute down through the next lines. So in my example below, it would just continue right down to LBL 01 and that's not what we want.

An example simple program would be

Code: Select all

LBL 00 		%this is your beginning label
"A"			%The text on your menu key
KEY 1 XEQ 01 	%menu key number 1
KEY 9 GTO 09 	%this will be your exit key
MENU		%Builds and displays the menu you created
STOP		%pauses the program (waiting for input)
GTO 00		%loops back, reloads the menu

LBL 01		%executed when key 1 is pressed

LBL 09		%Exits the program when EXIT key pressed
You can find "EXITALL" in the functions under CATALOG.
DM42 SN:00210
DM41X SN:00014
J Peters
Posts: 10
Joined: Wed Apr 18, 2018 9:53 am

Re: Having Trouble with User-Programmed Menus (Programming Query)

Post by J Peters »

Brilliant! Thank you so much, I love this forum.

When I first got the calculator I found programming it very complicated, so apart from using it as a 'straight' scientific, I haven't done much with it. I'm currently writing my own programming manual, really more of an idiot-aid, a few sheets of A4 with just the bits I need in it. This is why I'm currently going through it all again and pulling out the key points.

Thanks again.
Post Reply