Microsoft KB Archive/50005
COBOL 3.0 CALL X“AF” Enables/Disables Function Keys
PSS ID Number: Q50005 Article last modified on 04-20-1993
3.00 3.00a MS-DOS
|The information in this article applies to:|
|- Microsoft COBOL for MS-DOS, versions 3.0 and 3.0a|
Summary: The function keys of a COBOL 3.0 or 3.0a program can be enabled and disabled at any point during execution by invoking the X“AF” subprogram with CALL. The second argument in the parameter list of the subprogram contains fields that specify the following: 1. Whether to enable or disable the function key(s) 2. The number of the first function key to enable/disable 3. The total number of consecutive keys to enable/disable For detailed information, consult the “Microsoft COBOL 3.0: Operating Guide,” pages 8-16 to 8-18.
More Information: During the execution of an ACCEPT statement, certain keys are recognized by the COBOL system as termination keys. These are referred to as “function keys” and include such keys as ESC (Escape), the keys F1 (Function 1) through F12 (Function 12), and several others. By default, the only key that can terminate an ACCEPT statement is the ENTER key. This can be changed by turning on the other function keys using the ADISCF.EXE utility. However, this method turns on ALL the function keys and, thus, provides many different ways (perhaps accidentally) to terminate an ACCEPT. CALLing the subprogram X“AF” provides a way to turn on or off any number of the function keys during program execution. The syntax is the following: CALL X“AF” USING flag,parameter The argument “flag” is a PIC 99 COMP-X field whose value must be 1. The argument “parameter” is a group item consisting of four fields: 1. A PIC 99 COMP-X field that contains 0 (zero) to disable function keys or 1 to enable them. 2. A PIC X field whose value must be “1”. 3. A PIC 99 COMP-X field that contains the number of the first function key to be enabled or disabled. This number is as defined with the ADISCF utility. 4. A PIC 99 COMP-X field that specifies the number of consecutive function keys that are to be enabled or disabled. The following code example demonstrates how to enable and disable function keys during the execution of a program (on the fly). IDENTIFICATION DIVISION. PROGRAM-ID. FUNCTION-KEYS-ON-OFF. DATA DIVISION. WORKING-STORAGE SECTION. 01 flag PIC 99 COMP-X VALUE 1. 01 parameter. * “on-or-off” specifies whether to enable or disable. 05 on-or-off PIC 99 COMP-X. 05 dummy PIC X VALUE “1”. * “first-key” specifies the number of the first key in the * sequence to enable or disable. 05 first-key PIC 99 COMP-X. * “total-keys” specifies the total number of consecutive keys * (starting with “first-key”) to enable or disable. For * example, if “first-key” equals 0 and “total keys” equals 5, * then the function keys with numbers 0 through 4 would be * affected. 05 total-keys PIC 99 COMP-X. 01 accept-field PIC X(5). SCREEN SECTION. 01 accept-screen. 05 BLANK SCREEN. 05 pic X(5) to accept-field. PROCEDURE DIVISION. * By default, ADIS is configured to have ALL function keys * turned off, so only the ‘Enter’ key will terminate an * ACCEPT statement. DISPLAY accept-screen. DISPLAY “Only the ‘Enter’ key terminates this ACCEPT.”. ACCEPT accept-screen. * Putting 1 in “on-or-off” specifies to enable the keys. MOVE 1 TO on-or-off. * Putting 0 in “first-key” specifies the ‘Esc’ key as the * first key in the sequence. MOVE 0 TO first-key. * Putting 5 in “total-keys” specifies that the ‘Esc’ key and * the next 4 keys in the sequence are to be affected. The * next 4 function keys are ‘F1’ through ‘F4’. MOVE 5 TO total-keys. CALL X“AF” USING flag,parameter. DISPLAY accept-screen. DISPLAY “Now the ‘Esc’ key and the keys ‘F1’ through ‘F4’ -”(plus ‘Enter’) will terminate the next ACCEPT.“. ACCEPT accept-screen. * Putting 0 in”on-or-off" specifies to disable the keys. MOVE 0 TO on-or-off. * Putting 2 in “first-key” specifies the ‘F2’ key as the * first key in the sequence. MOVE 2 TO first-key. * Putting 2 in “total-keys” specifies that the ‘F2’ key and * the next key in the sequence are to be affected. The next * function key is ‘F3’. Note that the keys that were enabled * in the previous CALL statement are not affected (that is, * ‘Esc’, ‘F1’, and ‘F4’ will not be disabled) because their * key numbers are not included in the sequence. MOVE 2 TO total-keys. CALL X“AF” USING flag, parameter. DISPLAY accept-screen. DISPLAY “Now the ‘Esc’,‘F1’,and ‘F4’ keys (plus ‘Enter’) -”will terminate the next ACCEPT.". ACCEPT accept-screen. STOP RUN.
Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.