Microsoft KB Archive/34914

How to DISPLAY Graphics Characters in COBOL 3.0

PSS ID Number: Q34914 Article last modified on 04-21-1993

3.00 | 3.00 MS-DOS | OS/2

Summary: The following program demonstrates how graphics characters, such as hearts and smiling faces, can be displayed to the screen in a COBOL Version 3.0 program. A graphics character can be stored in your COBOL program as a hexadecimal constant representing the ASCII value of the desired character. The hexadecimal constant can be stored in a WORKING-STORAGE variable, stored in the SCREEN SECTION, or DISPLAYed directly. You can also type the control character directly into a quoted value in the program source file, as shown further below.

More Information: ASCII-byte values of 1 through 31 are often referred to as control characters, and most are associated with a certain graphics character on MS-DOS computers. For example, an ASCII value of 3 is a heart, 4 is a diamond, 5 is a club, 6 is a spade. Extended-ASCII characters (byte values of 128 through 255) are also associated with graphics characters, such as line-drawing graphics and foreign-alphabet letters. For documentation of the graphics characters associated with ASCII bytes, please see the Microsoft QuickBASIC Version 4.0 Language Reference manual or the IBM BASICA manual. The following is a code example: DATA DIVISION. WORKING-STORAGE SECTION. 01 TEMPVAL PIC X VALUE X“02”. SCREEN SECTION. 01 TEST-SCREEN. 05 LINE 10 COLUMN 10 VALUE X“02”. PROCEDURE DIVISION. ONLY-PARA. * The following displays an inverse smiling face directly: DISPLAY X“02”. * The following displays inverse an smiling face through * a variable in WORKING-STORAGE: DISPLAY TEMPVAL. STOP-RUN. * The following statement displays a graphics character * through the SCREEN SECTION. In this case the graphics * character is an inverse smiling face: DISPLAY TEST-SCREEN. The following program shows how to use control characters that are typed directly into quoted values in the source file. When you type the following program into your text editor, replace the “@” character with the desired control character as follows: while holding down the ALT key, press 002 (or the desired three-digit ASCII value) on the numeric keypad. (Note that certain text editors may not allow you to type certain control characters using the ALT key method.) DATA DIVISION. WORKING-STORAGE SECTION. * Type ALT+0+0+2 instead of @ on the following line: 01 IIX PIC X(1) VALUE ‘@’. SCREEN SECTION. 01 BLANK-SCREEN. 03 BLANK SCREEN. 01 TUTOR-SCREEN. 03 LINE 5 COLUMN 1 PIC X(1) USING IIX. PROCEDURE DIVISION. ONLY-PROC. DISPLAY BLANK-SCREEN. DISPLAY IIX. DISPLAY TUTOR-SCREEN. STOP-RUN.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.