Microsoft KB Archive/50467
COBOL 3.00 Can Trap CTRL+S and Make It Terminate ACCEPTs
PSS ID Number: Q50467 Article last modified on 11-03-1989
3.00 3.00a | 3.00 3.00a MS-DOS | OS/2
Summary: Microsoft COBOL 3.00 and 3.00a can trap the CTRL+S key combination by using the CALL X“AF” routine. You can optionally make the CTRL+S keystroke terminate an ACCEPT statement, or you can completely ignore CTRL+S. This technique can be used to prevent the user from pausing screen scrolling and to prevent a known hanging problem with pressing CTRL+C after CTRL+S. More information about this hanging problem can be found by querying on the following words: COBOL and 3.00 and CTRL+S and CTRL+C and hang CTRL+C cannot be trapped using this method. This information applies to Microsoft COBOL Versions 3.00 and 3.00a for MS-DOS and MS OS/2.
More Information: The following program demonstrates how to CALL X“AF” and make the CTRL+S key act as a terminator key. This program accepts keyboard input, and if CTRL+S terminates the accept, it displays “CTRL+S TERMINATED ACCEPT”:
$SET ANS85 ENVIRONMENT DIVISION. SPECIAL-NAMES. CRT STATUS IS KEY-STAT. DATA DIVISION. WORKING-STORAGE SECTION. 01 SET-BIT-PAIRS PIC 9(2) COMP-X VALUE 1. 01 DATA-KEY-CONTROL. 03 DATA-KEY-SETTING PIC 9(2) COMP-X. 03 FILLER PIC X VALUE "3". 03 FIRST-DATA-KEY PIC X. 03 NUMBER-OF-DATA-KEYS PIC 9(2) COMP-X. 01 KEY-STAT. 03 KEY-TYPE PIC 9. 03 KEY-CODE-1 PIC 99 COMP-X. 03 KEY-CODE-2 PIC 99 COMP-X. 01 DATA-ITEM PIC X. 01 SCAN-CODE-CTRL-S PIC 99 VALUE 19. SCREEN SECTION. 01 CLEAR-SCREEN. 03 BLANK SCREEN. PROCEDURE DIVISION. DISPLAY CLEAR-SCREEN. * Define the action of the affected keys: * 0 = Key is disabled. * 1 = Key will act as a function key. * It will terminate accepts. * 2 = (default) Key acts as normal. MOVE 1 TO DATA-KEY-SETTING. * Determine the first key to be affected: MOVE X"13" TO FIRST-DATA-KEY. * Determine the number of keys to be affected, * which is also the number of sequential scan codes * that will be changed by the CALL X"AF" routine. MOVE 1 TO NUMBER-OF-DATA-KEYS. * Make call to turn on CTRL+S key: CALL X"AF" USING SET-BIT-PAIRS DATA-KEY-CONTROL. ACCEPT DATA-ITEM AT 0101. * key-type indicates what type of key was * the terminator key: * key-type key-code-1 meaning * 0 0 The operator pressed a * terminator key. * 0 1 Auto-skip out of the last field. * 1 0-127 The function key number * 2 0-26 The function key number * 3 any Data key terminated accept. IF KEY-TYPE = "3" IF KEY-CODE-1 = 19 DISPLAY "CTRL+S TERMINATED ACCEPT" END-IF END-IF. STOP-RUN.
Copyright Microsoft Corporation 1989.