Microsoft KB Archive/60861

CALL X“A7” to Display All Foreground/Background Colors

PSS ID Number: Q60861 Article last modified on 04-19-1990

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

Summary: The CALL X“A7” subprogram can be called to alter foreground and background colors when using DISPLAY statements for nonscreen data-items. It will not work on data that is defined in the SCREEN SECTION. The program below displays all the foreground and background combinations possible with the CALL X“A7” subprogram and the color value that must be passed to obtain a particular color combination. This information applies to Microsoft COBOL Compiler Versions 3.00 and 3.00a for MS-DOS and OS/2.

More Information: The syntax of the call is as follows: CALL X“A7” USING function, parameter The “function” argument is a PIC 99 COMP-X field defined in the following manner 6 - reads the current User attribute 7 - sets the current User attribute 16 - turns on or off the User attribute where User attribute is a byte in memory that stores the foreground and background colors. The “parameter” argument is a PIC 99 COMP-X field containing the following information: for function 6 - not relevant for function 7 - the value to store in the User attribute for function 16 - 0 toggles User attribute on 1 toggles User attribute off The program in this article simply shows the foreground and background color combinations that display when the “function” value is set to 7 and the “parameter” value is varied. For a more detailed description of the CALL X“A7” subprogram and how these “parameter” values are derived, query on the following words: CALL AND X“A7” AND foreground AND background If “parameter” is a value between 0 and 127, the foreground and background colors are displayed with normal color intensity and do not blink. If “parameter” is a value between 128 and 256, the display blinks unless Interrupt 10 Hex, Function 10 Hex, Subfunction 03 Hex is called. If this interrupt is performed prior to calling the CALL X“A7” subprogram, the display does not blink. Sending “parameter” values ranging from 128 to 256 causes the background colors to be displayed in high intensity. If your program is running under OS/2 in protected mode, you do not need to call the interrupt to get the high-intensity backgrounds. For more information on displaying high-intensity background colors in COBOL, query on the following words: high-intensity AND background AND COBOL When the program shown below is run, the “parameter” value that is used to get a particular foreground/background combination is displayed in the foreground color it defines. The background surrounding the “parameter” value is in the background color it defines. The program should be compiled and linked as follows: COBOL GETCOLOR.CBL; LINK GETCOLOR + ADIS.OBJ + ADISINIT.OBJ + ADISKEY.OBJ;

Code Example
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. * Set up line and column display 01 LINE-NUM    PIC 99 VALUE 2. 01 COL-NUM     PIC 99 VALUE 1. * Set up Interrupt 10 to display high intensity background 01 INTERRUPT   PIC X VALUE X&quot;10&quot;. 01 FLAG        PIC X VALUE X&quot;FF&quot;. 01 AX. 05 A-H     PIC 99 COMP-X VALUE 16. 05 A-L     PIC 99 COMP-X VALUE 3. 01 BX. 05 B-H     PIC 99 COMP-X. 05 B-L     PIC 99 COMP-X VALUE 0. 01 CX. 05 C-H     PIC 99 COMP-X. 05 C-L     PIC 99 COMP-X. 01 DX. 05 D-H     PIC 99 COMP-X. 05 D-L     PIC 99 COMP-X. SCREEN SECTION. 01 CLEAR-SCREEN. 05 BLANK SCREEN. PROCEDURE DIVISION. DISPLAY CLEAR-SCREEN. * Toggle User attribute on. CALL X&quot;A7&quot; USING FUNCTION, PARAMETER. * Set the current User attribute MOVE 7 TO FUNCTION. MOVE 0 TO PARAMETER. PERFORM CHANGE-ATTRIBUTES 128 TIMES. DISPLAY &quot;High intensity background after calling interrupt&quot; AT LINE 12 COL 15. DISPLAY &quot; 10 Hex, function 10 Hex, subfunction 03 Hex:   &quot; AT LINE 13 COL 15. * Call interrupt 10 to allow for high intensity background * and display these colors MOVE 16 TO LINE-NUM. CALL X&quot;84&quot; USING INTERRUPT, FLAG, AX, BX, CX, DX. PERFORM CHANGE-ATTRIBUTES 128 TIMES. * Toggle User attribute off MOVE 16 TO FUNCTION. MOVE 1 TO PARAMETER. CALL X&quot;A7&quot; USING FUNCTION, PARAMETER. STOP RUN. CHANGE-ATTRIBUTES. CALL X&quot;A7&quot; USING FUNCTION, PARAMETER. DISPLAY PARAMETER AT LINE LINE-NUM COL COL-NUM. IF COL-NUM >=76 THEN MOVE 1 TO COL-NUM ADD 1 TO LINE-NUM ELSE ADD 5 TO COL-NUM. ADD 1 TO PARAMETER. Copyright Microsoft Corporation 1990.