Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕PFKEY Set up Function keys
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕PFKEY Set up Function keys


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.

Associating a sequence of strings with a function key

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:

  • Presentations, where you want to pre-store a set of lines (or fragments of lines) rather than typing them in during the talk
  • Storing a set of useful commands which you can cycle through in order to select the one you want.

Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕PFKEY Set up Function keys
[ Previous | Next | Contents | Index | APL Home ]