The system function ŒPFKEY
function allows you to associate your own strings with function keys. It takes
a left argument which is the character string you want to associate with the
key (with a closing ŒR or ŒTCNL character if you want to simulate
pressing Return at the end). The right
argument is a numeric scalar giving the key number. The range 1 to 15 corresponds to function keys F1 to F15. Add 15 to the value to represent the shifted
key, and 30 to the value to represent the key with Control held down. For example, the following two commands
would cause F5 to execute a )WSID command and Shift-F5 to execute
a )TIME
command, in the session window:
(')WSID',ŒR) ŒPFKEY 5 (')TIME',ŒR) ŒPFKEY 5+15
The strings you attach can be used for any purpose you
like, either as short-cuts in APL development, or within your application. However, be aware that some function-key combinations may be reserved for use by the operating system or window-manager,
or as menu short-cuts. In this case programming the function key yourself may
not work (because the operating-system may intercept it before APLX sees the
keystroke), or may be incompatible with the user-interface guidelines for the
system you are using.
The exact implementation of this system function varies according to the host system. Under MacOS, the Control-key strings are not effective. In Linux Server Edition (dumb-terminal), neither the Shift nor Control-key strings are effective.
An extension to standard function-key programming allows you to associate a sequence of strings with a given function key. (This works with the Session window only). Each time you press the function key, the next string in the sequence is output to the session window, at the end of the current session. If you press the function key whilst Shift is held down, the previous string in the sequence is output. The sequence wraps round at the beginning and end.
To use this mode, supply a text matrix as the left argument of the ŒPFKEY. The right argument should be the function key number in the range 1 to 15. Each line of the matrix corresponds to a string in the sequence (trailing blanks are suppressed).
For example, you could program function key 2 as follows:
strings„'/' ŒBOX 'x„1/y„2/x run y' strings x„1 y„2 x run y strings ŒPFKEY 2
If you now press function key 2 four times in succession, the three strings will be output in turn, and then the sequence will wrap round to the first again on the fourth key press.
This facility is very useful for: