Microsoft KB Archive/66686

MS-DOS COBOL 4.00 Can Change Status of SHIFT and Toggle Keys

PSS ID Number: Q66686 Article last modified on 11-18-1990

4.00 MS-DOS

Summary: A COBOL version 4.00 program can change the state of the SHIFT keys (RIGHT SHIFT, LEFT SHIFT, CTRL, and ALT) and the toggle keys (SCROLL LOCK, NUM LOCK, CAPS LOCK, and INS) by calling X“86”. This subprogram can be used to set the byte value at 0000:1047 (in segment:offset notation). Each bit of that location reflects the status of one of the above keys. A code example that will toggle the CAPS LOCK key on is shown below. This information applies to Microsoft COBOL Professional Development System (PDS) version 4.00 for MS-DOS.

More Information: As mentioned above, each bit of the byte at location 0000:1047 reflects the status of the SHIFT or toggle keys. If the bit is set, the key is down (for the SHIFT keys) or on (for the toggle keys). If the bit is cleared, the opposite condition exists (up for the SHIFT keys, off for the toggle keys). The following is a description of the bits and the keys they represent:

The following example demonstrates how a COBOL 4.00 program can turn the CAPS LOCK key on using X“86”. To show this, the program prompts you to enter a letter. The letter will appear on the screen in uppercase. Note that because bit 6 of 0000:1047 represents the CAPS LOCK key, a 64 (2**6 equals 64) is written to the location to set that bit.

Code Example
DATA DIVISION. WORKING-STORAGE SECTION. 01 Seg     PIC 9(5) VALUE 0. 01 Offset  PIC 9(5) VALUE 1047. 01 Letter  PIC X.   PROCEDURE DIVISION. CALL X&quot;86&quot; USING Seg, Offset, X&quot;40&quot;. DISPLAY &quot;Enter a letter:&quot;. ACCEPT Letter. STOP RUN. For a separate article describing how to read the status of SHIFT and toggle keys, search for the following words in this Knowledge Base: COBOL and read and SHIFT and toggle and 85

Copyright Microsoft Corporation 1990.