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!
Program menu; key press remembered?
Program menu; key press remembered?
DM42 s/n 06181 DM41X s/n \(\beta\)0005 (sold)
Re: Program menu; key press remembered?
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
-
- Posts: 1102
- Joined: Tue May 02, 2017 5:48 pm
- Location: Netherlands
- Contact:
Re: Program menu; key press remembered?
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.)
Re: Program menu; key press remembered?
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)
-
- Posts: 795
- Joined: Wed May 03, 2017 7:46 pm
- Location: Malone, NY USA
Re: Program menu; key press remembered?
Could each key store a different address in a register rather than XEQ and then do an indirect jump to that address?jthole wrote: ↑Mon Dec 14, 2020 8:36 amWhen 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!
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)
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)
Re: Program menu; key press remembered?
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 nowtoml_12953 wrote: ↑Mon Dec 14, 2020 2:35 pmCould each key store a different address in a register rather than XEQ and then do an indirect jump to that address?
DM42 s/n 06181 DM41X s/n \(\beta\)0005 (sold)
Re: Program menu; key press remembered?
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
// 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