Microsoft KB Archive/58958

CALL X“A7” Specifies Foreground/Background Colors for DISPLAYs

PSS ID Number: Q58958 Article last modified on 02-28-1990

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: The COBOL subprogram X“A7” can specify the foreground and background colors to be used in DISPLAY statements that operate on nonscreen data items. This subprogram sets, reads, and toggles on/off the User attribute. The User attribute is a byte in memory that stores the foreground and background colors to be used. Two arguments are passed to the X“A7” subprogram. The syntax of the call is as follows: CALL X“A7” USING function, parameter Here, “function” is a PIC 99 COMP-X field (the manual fails to mention this critical information) that contains a value indicating the function required, as follows: 6 - reads the current User attribute 7 - sets the current User attribute 16 - turns on or off the User attribute “parameter” is a PIC 99 COMP-X field containing the following: for function 6 - not relevant for function 7 - the value to store in the User attribute for function 16 - 0 to turn the User attribute on 1 to turn the User attribute off This information applies to Microsoft COBOL Compiler Versions 3.00 and 3.00a for MS-DOS and MS OS/2.

More Information: The User attribute must be turned on with X“A7” to be used; initially it is off. Once turned on, it remains on until it is explicitly turned off. The User attribute affects all DISPLAYs of nonscreen data names while it is on and also overrides any Screen attributes set for the individual characters of the screen. For more information on Screen attributes, refer to Pages 8-22 and 8-23 of the “Microsoft COBOL Compiler 3.0: Operating Guide” for Versions 3.00 and 3.00a. For an example on how to manipulate Screen attributes, query on the following words in this Knowledge Base: CALL X“b7” The format of the User attribute is as follows: +——-+——-+——-+——-+——-+——-+——-+——-+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +——-+——-+——-+——-+——-+——-+——-+——-+ | | | | | | | |_______________________| | |_______________________| | | | | blinking background color intensity foreground color If you want the foreground color to be blinking, set bit 7. Bit 3, the intensity bit, is set when a foreground color greater than 7 is desired. For example, the User attribute will appear as follows if the foreground color is set to yellow (color number 14) and the background color is set to red (color number 4): 7 6 5 4 3 2 1 0 +——-+——-+——-+——-+——-+——-+——-+——-+ | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | +——-+——-+——-+——-+——-+——-+——-+——-+ | | | | | | | |_______________________| | |_______________________| | | | | blinking background color intensity foreground color This example becomes clear when the colors yellow and red are broken down into sums of powers of 2 (2^bit, where bit is a number from 0 to 7), as follows: yellow = 2^3 + 2^2 + 2^1 red = 2^2, but shifting it left four bits as required by the diagram above yields 2^6 The User attribute will be as follows: 2^6 + 2^3 + 2^2 + 2^1 = 64 + 8 + 4 + 2 = 78 The following is another example with a blinking, light magenta (color 13) foreground and a green (color 2) background: 7 6 5 4 3 2 1 0 +——-+——-+——-+——-+——-+——-+——-+——-+ | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | +——-+——-+——-+——-+——-+——-+——-+——-+ | | | | | | | +———–+———–+ | +———–+———–+ | | | | blinking background color intensity foreground color light magenta = 2^3 + 2^2 + 2^0 green = 2^1, but shifting it left four bits yields 2^5 blinking bit = 2^7 Thus, the User attribute will be as follows: 2^7 + 2^5 + 2^3 + 2^2 + 2^0 = 128 + 32 + 8 + 4 + 1 = 173 Once the value for the desired colors has been determined, you can use function 16 of the X“A7” subprogram to toggle the User attribute on and function 7 to store the computed value in the User attribute. If you want to find out what the current attribute is, use function 6. The following sample program illustrates the use of the X“A7” subprogram: DATA DIVISION. WORKING-STORAGE SECTION. * Set up arguments for toggling User attribute on. 01 function PIC 99 COMP-X VALUE 16. 01 parameter PIC 99 COMP-X VALUE 0. SCREEN SECTION. * Remember, the User attribute will not affect screens. 01 a-screen. 05 BLANK SCREEN. 05 &quot; This will not be colored “. 05”because this is a screen definition.“. 05 LINE 2” “. PROCEDURE DIVISION. * Toggle User attribute on. CALL X”A7&quot; USING function, parameter. * Set User attribute to yellow foreground, red background. MOVE 7 TO function. MOVE 78 TO parameter. CALL X“A7” USING function, parameter. DISPLAY a-screen. DISPLAY “This is yellow on red.”. * Read the User attribute. MOVE 6 TO function. CALL X“A7” USING function, parameter. * Display current User attribute. DISPLAY &quot; The current User attribute is:&quot; DISPLAY parameter. * Set User attribute to blinking, light magenta foreground * and green background. MOVE 7 TO function. MOVE 173 TO parameter. CALL X“A7” USING function, parameter. DISPLAY &quot; This is blinking, light magenta on green.&quot; * Toggle User attribute off. MOVE 16 TO function. MOVE 1 TO parameter. CALL X“A7” USING function, parameter. DISPLAY &quot; This will not be colored because the&quot; DISPLAY &quot; User attribute has been turned off.&quot; STOP RUN.

Copyright Microsoft Corporation 1990.