Here is an alternative way by reusing ED way of doing things.
Example of key mapping
Code:
Key mapping interaction description
01 exit interactive leave program
-01 exit interactive leave program
15 +50 records interactive go forward 50 records, make it current and show it
-15 -50 records interactive go backward 50 records, make it current and show it
25 +10 records interactive go forward 10 records, make it current and show it show it
-25 -10 records interactive go backward 10 records, make it current and
Code:
-34 goto record user entry stop, enter record number, then R/S, make it current and show it
35 next record interactive go forward 1 record, make it current and show it
-35 previous record interactive go backward 1 record, make it current and show it
41 mantissa interactive
-41 data entry user entry stop, enter new data for current record, then R/S, ask user to confirm update and show it
84 add record after interactive add record after current, make it current and show it
-84 add record before interactive add record before current, make it current and show it
Focal code that go with it: (the code use key code as numeric label)
Code:
LBL "XMDE" // Extended Memory Data Editor
"XM DATA EDIT" // program title
AVIEW // show title
PSE // give user time to see it
CLA // clear alpha
AVIEW // clear screen
// --------------------------------
Code:
LBL 90 // unshifted key press handling
CF 01 // clear shift indicator flag
SF 04 // set key scanning active flag
CF 05 // clear double shift key trap
GETKEY // wait for key press (10 seconds)
CF 04 // clear key scanning active flag
SF 25 // forget GTO IND X error
Code:
X<>0? // has a key been pressed ?
GTO IND X // yes, go to handling label
GTO 90 // no key pressed or no key hanling so loop for more unshifted key
// --------------------------------
LBL 31 // shifted key press handling
FS?C 05 // is shift key has been pressed ?
GTO 90 // yes, go loop for unshifted key
Code:
SF 01 // set shift indicator flag
SF 04 // set key scanning active flag
GETKEY // wait for key press (10 seconds)
CF 04 // clear key scanning active flag
X=0? // has a key been pressed ?
GTO 31 // no key pressed so loop for more shifted key
CHS // indicate to the receiving label that a shift key has been pressed
Code:
SF 05 // flag to indicate we are processing a shifted key
SF 25 // forget GTO IND X error
GTO IND X // go to handling label
CF 05 // shifted key processing finished
GTO 90 // no key hanling so loop for more unshifted key
// --------------------------------
LBL 01 // ON KEY (01) handling
GTO 99 // run exit code
Code:
// --------------------------------
// begin - logic template
LBL XX // key handling code, replace XX with keycode value
X<0? // is kep pressed was shifted ?
GTO 00 // yes, go to shifted key handler
// unshifted logic here
GTO 90 // go to key press handler
Code:
LBL 00 // shifted key handler
// shifted logic here
GTO 90 // go to key press handler
// end - logic template
// --------------------------------
LBL 99 // exit logic
CF 01 // clear shift indicator flag
Code:
CF 04 // clear key scanning active flag
CF 25 // enable error
"EXIT" // exit message
AVIEW // show message
END // end of program
Flag used
Code:
01 shift indicator flag
04 GETKEY is active, allow user to see when a key press is accepted, for original low speed HP-41s
05 use to detect double shift key press
Sylvain