Program menu; key press remembered?

Discussion around the SwissMicros DM42 calculator
Post Reply
jthole
Posts: 129
Joined: Mon Nov 27, 2017 8:46 pm
Location: Netherlands

Program menu; key press remembered?

Post by jthole »

When I define menu keys in a program with KEYX or KEYG, are the key presses stored in a register?

That means I could do something like this:

"CHOICE 1"
KEY 1 XEQ 01
"CHOICE 2"
KEY 2 XEQ 01
...
LBL 01
<retrieve key number pressed>
<do something with the key number>
RTN

instead of having each key press jumping to its own label.
(Yes, I used the search, and read the manual, but couldn't find it.)

Thanks!
DM42 s/n 06181 DM41X s/n \(\beta\)0005 (sold)
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: Program menu; key press remembered?

Post by Walter »

How about using a flag to differentiate between two alternatives?
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Program menu; key press remembered?

Post by Thomas Okken »

jthole wrote:
Mon Dec 14, 2020 8:36 am
When I define menu keys in a program with KEYX or KEYG, are the key presses stored in a register?
No. You can check whether or not Shift was pressed by testing flag 64, but for which key was pressed, the only information you have is which LBL was called.

(The flag 64 thing is a DM42/Free42 feature. It does not work on a real HP-42S or in Emu42.)
jthole
Posts: 129
Joined: Mon Nov 27, 2017 8:46 pm
Location: Netherlands

Re: Program menu; key press remembered?

Post by jthole »

Walter wrote:
Mon Dec 14, 2020 9:48 am
How about using a flag to differentiate between two alternatives?
In my case, I have five alternatives. I am going to use five different labels, and calling a common subroutine from there (with different values, of course).

Thanks @Walter and @Thomas Okken!
DM42 s/n 06181 DM41X s/n \(\beta\)0005 (sold)
toml_12953
Posts: 795
Joined: Wed May 03, 2017 7:46 pm
Location: Malone, NY USA

Re: Program menu; key press remembered?

Post by toml_12953 »

jthole wrote:
Mon Dec 14, 2020 8:36 am
When I define menu keys in a program with KEYX or KEYG, are the key presses stored in a register?

That means I could do something like this:

"CHOICE 1"
KEY 1 XEQ 01
"CHOICE 2"
KEY 2 XEQ 01
...
LBL 01
<retrieve key number pressed>
<do something with the key number>
RTN

instead of having each key press jumping to its own label.
(Yes, I used the search, and read the manual, but couldn't find it.)

Thanks!
Could each key store a different address in a register rather than XEQ and then do an indirect jump to that address?
Tom L

Some people call me inept but I'm as ept as anybody!
DM10L SN: 059/100
DM41X SN: 00023 (Beta)
DM41X SN: 00506 (Shipping)
DM42 SN: 00025 (Beta)
DM42 SN: 00221 (Shipping)
WP43 SN: 00025 (Prototype)
jthole
Posts: 129
Joined: Mon Nov 27, 2017 8:46 pm
Location: Netherlands

Re: Program menu; key press remembered?

Post by jthole »

toml_12953 wrote:
Mon Dec 14, 2020 2:35 pm
Could each key store a different address in a register rather than XEQ and then do an indirect jump to that address?
Maybe a possibility, but I am not sure that improves my current code. I think I am not going to spend more time on it now :)
DM42 s/n 06181 DM41X s/n \(\beta\)0005 (sold)
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Re: Program menu; key press remembered?

Post by ferni123 »

In case it helps, I usually solve the issue using a variable like "ik" as in the following code. In that code XEQ 42 can check the key pressed looking at "ik":

// build menu
CLMENU
XEQ D
KEY 1 GTO 01
XEQ D
KEY 2 GTO 02
XEQ D
KEY 3 GTO 03
XEQ D
KEY 4 GTO 04
XEQ D
KEY 5 GTO 05
XEQ D
KEY 6 GTO 06
KEY 7 GTO 07
KEY 8 GTO 07
KEY 9 GTO "UNIT"
// initialisation of ik
XEQ 41
SF 22
MENU
LBL 07
STOP
GTO 07
// identification of key pressed in ik
LBL 06
ISG "ik"
LBL 05
ISG "ik"
LBL 04
ISG "ik"
LBL 03
ISG "ik"
LBL 02
ISG "ik"
LBL 01
// activate/deactivate fix unit mode
XEQ 42
Post Reply