Microsoft KB Archive/38490

Format 2 DISPLAY Forgets New Default COLOR & Video Attributes

PSS ID Number: Q38490 Article last modified on 04-20-1993

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

Summary: The DISPLAY statement is described in the “Microsoft COBOL Compiler Version 3.0: Language Reference Manual” on Page 15-54. The Format 2 of the DISPLAY statement may be used to set color and other text attributes, one particular attribute being the BACKGROUND-COLOR. After using such a statement, any DISPLAY or ACCEPT should then default to the setting the previous Format 2 DISPLAY used. However, as demonstrated in the first sample program below, this is not the case. After any reference in the PROCEDURE DIVISION to any of the following attributes, the default setting becomes a white foreground on black background and cannot be reset even by using another SCREEN SECTION display: FOREGROUND-COLOR BACKGROUND-COLOR HIGHLIGHT BLINK UNDERLINE REVERSE VIDEO

More Information: Microsoft has confirmed this to be a problem in COBOL versions 3.0 and 3.0a. This problem was corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2. The second sample program below demonstrates a reasonable workaround. The programs below can be compiled and linked with the default settings: COBOL progname; LINK progname; The following sample program demonstrates the problem: WORKING-STORAGE SECTION. 01 MYDATA PIC X(30) VALUE “This is not good”. SCREEN SECTION. 01 COLOR-SCREEN. 02 BLANK SCREEN FOREGROUND-COLOR 6 BACKGROUND-COLOR 1. PROCEDURE DIVISION. MAIN. DISPLAY COLOR-SCREEN. DISPLAY “TESTING” ACCEPT MYDATA AT 0230 WITH HIGHLIGHT FOREGROUND-COLOR 15 BACKGROUND-COLOR 1. DISPLAY MYDATA AT 0101. ACCEPT MYDATA. DISPLAY COLOR-SCREEN. DISPLAY “TESTING”. ACCEPT MYDATA AT 1020. DISPLAY MYDATA AT 2020. STOP RUN. The following sample program demonstrates a workaround solution: WORKING-STORAGE SECTION. 01 ToPrint PIC X(30) VALUE “STARTING HERE”. 01 CURSOR-POS. 02 AROW PIC 99 VALUE 10. 02 ACOL PIC 99 VALUE 02. SCREEN SECTION. 01 COLOR-SCREEN. 02 BLANK SCREEN FOREGROUND-COLOR 3 BACKGROUND-COLOR 5. 01 WHITE-ON-BLUE. 02 LINE AROW COLUMN ACOL FOREGROUND-COLOR 7 BACKGROUND-COLOR 1 PIC X(80) USING ToPrint. 01 BLUE-ON-RED. 02 LINE AROW COLUMN ACOL FOREGROUND-COLOR 1 BACKGROUND-COLOR 6 PIC X(80) USING ToPrint. PROCEDURE DIVISION. ONLY-PARA. DISPLAY COLOR-SCREEN. DISPLAY WHITE-ON-BLUE. MOVE “GOING TO HERE” TO ToPrint. MOVE “1010” TO CURSOR-POS. DISPLAY BLUE-ON-RED. DISPLAY “AND BACK” AT 2010. STOP RUN.

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