Hi,
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
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.
Having Trouble with User-Programmed Menus (Programming Query)
Re: Having Trouble with User-Programmed Menus (Programming Query)
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
You can find "EXITALL" in the functions under CATALOG.
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 "TEST"
LBL 00 %this is your beginning label
CLMENU
"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
1
ENTER
+
RTN
LBL 09 %Exits the program when EXIT key pressed
END
DM42 SN:00210
DM41X SN:00014
DM41X SN:00014
Re: Having Trouble with User-Programmed Menus (Programming Query)
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.
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.