Microsoft KB Archive/42330

From BetaArchive Wiki

Using X“83” in COBOL 3.0 to Read Character from Keyboard

PSS ID Number: Q42330 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: Microsoft COBOL Versions 3.0 and 3.0a include a special function which can be used to read a character from the keyboard. This function is CALL X“83”. See Page 8-3 of the “Microsoft COBOL Version 3.0: Operating Guide” for a complete description. The program example shown below demonstrates one method of using CALL X“83” to display the character, or in the case of a FUNCTION KEY, display the scan code. This call was not available in versions of COBOL prior to Version 3.0. The following is sample code: special-names. console is CRT. working-storage section. 01 CHAR. 03 S1 pic x. 03 S2 pic x. 01 SCAN redefines CHAR pic 9(4) comp-x. 01 display-scan pic 99. 01 ANULL PIC X VALUE X“00”. procedure division. main. DISPLAY SPACES UPON CRT. DISPLAY “PRESS Q TO QUIT”. PERFORM GETKEY UNTIL S1 =“Q”. STOP RUN. GETKEY. CALL X“83” USING S1. DISPLAY “CHARACTER :” AT 2001. DISPLAY S1 AT 2013. DISPLAY " " AT 2014. IF S1 = ANULL THEN CALL X“83” USING S2 DISPLAY “FUNCTION’S SCAN CODE :” AT 2001 move scan to display-scan DISPLAY display-SCAN AT 2022.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.