Using Application-Defined Function Keys
As an example of setting up and using the Application Function key, assume that the following keys have been defined, as detailed previously.
Processing
The developer first initializes the Toolkit environment using _acu.utl and loads the keymap with _lkeymap.utl. The application sets up the screen (using whatever method necessary) and prepares the input variable, which is required by the _ninput.utl program. The application program then CALLs the input processing program, passing it the appropriate values.
When _lkeymap.utl initializes the keymap, it makes the key label, action, and keystroke names available to the application program via global strings. The keystroke descriptions are available to the developer, based upon the CTLVAL, by the use of the STBL(#Fnn), wherennrepresents the CTLVAL to be tested. If an application uses these global values, STBL("F7") returns the name of the key that will generate the <SEARCH> function (default F5).
The application keys label and the action assigned (if any) are also available to the developer. The format is (#APP1) - key label assigned to App1, (#ACT1) - action assigned to App1, and (#F55) - keystroke assigned to App1.
Using these values, the application program creates a prompt string:
LET PROMPT$=STBL("#F55")+" to "+STBL("#APP1")+" or "+STBL("#F56")+" to call "+STBL("#APP2")
This inserts the appropriate key labels in the prompt string and makes it visible to the user:
F7 to DELETE or F9 to call CALCULATOR
Input Processing
If the F9 key were pressed, the input program would CALL the _calc program. After exiting _calc, the input program would continue to process input. If the F7 key were pressed, input would stop, the CTLVAL variable would be assigned the value of 55, and control would return to the application program. The application program would then determine what action to take, given this value.
This same logic is applied to other function and edit keys. The input process either processes these keys internally and/or sets the CTLVAL variable and returns to the application program.