Microsoft KB Archive/35655

IBMCOMP Compiler Directive Corrupts Key Trapping; COBOL 3.0

PSS ID Number: Q35655 Article last modified on 04-21-1993

3.00 | 3.00 MS-DOS | OS/2

Summary: If the IBMCOMP language directive is used with the COBOL Version 3.0 Compiler, the values returned by key trapping are altered and give nonconsecutive, incorrect values. Without the IBMCOMP directive, the values are correct. Microsoft has confirmed this to be a problem in Version 3.0. This problem was corrected in Version 3.0a.

More Information: In the code sample below, the values returned by the ACCEPT from the ESC key correspond to the terminator function key last pressed (i.e., 01=ESC, 02=F1, 03=F2, etc.). With the IBMCOMP directive set, the values are changed without pattern, as in the following partial table: Key NOIBMCOMP IBMCOMP F1 02 12 F2 03 68 F3 04 24 F4 05 80 (etc.) To work around this problem, do not use the IBMCOMP directive when compiling programs that do key trapping. The following is a code example:   Example: Finding values representing function keys. * Compile this program with and without the * IBMCOMP directive to demonstrate problem. * WORKING-STORAGE SECTION. 77 ESCAPE-CODE PIC 99 VALUE 00. 77 ACCEPT-FIELD PIC XX. 77 ESCAPE-KEY PIC 99 VALUE 01. 77 STOP-FLAG PIC X VALUE “N”. 01 FUNCTION-KEYS. 05 FUNCT10 PIC 99 VALUE 11. SCREEN SECTION. 01 CLEAR-SCREEN. 03 BLANK SCREEN. 01 MENU-SCREEN. 03 LINE 1 COLUMN 1 VALUE “PRESS ANY FUNCTION KEY:”. 03 COLUMN PLUS 3 PIC XX USING ACCEPT-FIELD. 03 LINE PLUS 2 COLUMN 1 VALUE “(F10 WILL TERMINATE EXECUTION.)”. 01 KEY-VALUE. 03 LINE 1 COLUMN 40 VALUE “KEY VALUE:”. 03 COLUMN PLUS 2 PIC 99 USING ESCAPE-CODE. PROCEDURE DIVISION. PARA1. DISPLAY CLEAR-SCREEN. PERFORM KEY-LOOP UNTIL STOP-FLAG = “Y”. STOP RUN. KEY-LOOP. DISPLAY MENU-SCREEN, ACCEPT MENU-SCREEN ACCEPT ESCAPE-CODE FROM ESCAPE KEY. DISPLAY KEY-VALUE. EVALUATE TRUE WHEN ESCAPE-CODE = FUNCT10 MOVE “Y” TO STOP-FLAG END-EVALUATE.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.