Softkey Macros
The softkey macro facility allows you to define a macro sequence and associate it with a function key. When you press that function key, the macro sequence is entered into the input buffer just as if you had typed it in from the keyboard. A softkey definition can be quite complex and it can even call other softkey definitions. You can assign, edit, read, delete, list, store and load softkey macros.
Assigning Softkeys
SET KEY key,string is used to assign an arbitrary string of characters (including two-char function codes) to special purpose function keys. For Example, to define a softkey macro to RENumber and INDENT the current program and then put you into Edit mode, you could define function key 9 as follows:
L$ = CHR$(255)&"#" !Clear Line
S$ = CHR$(255)&"K" !Clear Screen
E$ = CHR$(255)&"E" !Execute Input
D$ = CHR$(255)&"D" !EDIT
SET KEY 9,"INDENT RENUMBER"&L$&S$&"REN"&E$&"INDENT"&E$&D$&E$
You are only limited by your imagination in defining softkey macros.
Editing Softkeys
EDIT KEY key_num, where n is the softkey number allows interactive editing of softkey macros. You can also press EDIT followed by the softkey function key_num you wish to edit and then the ENTER key. If the softkey has been defined, the old definition will be displayed. You can modify the old definition by over-striking the existing characters or inserting new characters. Pressing ENTER saves the new softkey definition.
Reading Softkeys
READ KEY key_num,str-var$ returns one or more softkey macro definitions. Specify the key number of the softkey macro to read. If a simple string or array element is specified, then only one key is returned. If a string array is specified, then successive keys are returned into the elements of the string array starting with the key_num specified. For example:
READ KEY 2,Keytwo$ ! One macro
READ KEY First_key,Keys$(*) ! Several macros
Deleting Softkey Macros
SCRATCH KEY [key_num] removes softkey macro definitions for key_num or all keys if no key_num is specified. For example:
SCRATCH KEY 3
Listing Softkey Macros
LIST KEY [Isc] lists the current softkey macro definitions on the PRINTER IS device or to the specified Interface-select-code output device.
Storing Softkey Macros
The STORE KEY statement saves all the current softkey macro definitions in a new file of type BDAT. HTBasic softkey BDAT files are compatible with HP BASIC softkey BDAT files when HPCOPY is used to move the files. The definition for each defined softkey is written to the file by outputting two items using FORMAT OFF. The first item is an integer, specifying the key number. The second item is a string, giving the key definition. For example:
STORE KEY "Helpers"
This saves the current softkey macro definitions into a new BDAT file named Helpers. If the file already exists, an error is reported. Use RE-STORE KEY to update an existing file.
Loading Softkey Macros
Use LOAD KEY to reload softkey macros:
LOAD KEY "Helpers"