Microsoft KB Archive/40035

REDEFINES with COMP-0 Allows Any ASCII Character in PIC X

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

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

Summary: Any ASCII character may be placed into a PIC X field. Normal characters may be used simply by MOVEing a literal character to the data item. The MOVE statement does not support moving ASCII characters 0 through 31 or 128 through 255. To place these characters into a PIC X field, the PIC X field should be REDEFINEd with a subsequent COMP-0 field.

More Information: To set up the redefinition properly, a 2-byte PIC X field must be created. These two bytes must be REDEFINEd with a PIC S9(4) COMP-0 field, which is a 2-byte integer stored in high-byte, low-byte format. Moving the ASCII code to the COMP-0 field causes the second byte of the PIC X field to be that character. This field may be used just like any other text field. The following program will print the ASCII character of the number entered: $set ANS85 DATA DIVISION. WORKING-STORAGE SECTION. 77 FIELD-1 PIC S9(4) COMP-0. 01 FIELD-2 REDEFINES FIELD-1. 05 DUMMY-FIELD PIC X. 05 CONVERT-FIELD PIC X. SCREEN SECTION. 01 BLANK-SCREEN. 05 BLANK SCREEN. PROCEDURE DIVISION. DISPLAY BLANK-SCREEN. DISPLAY “ENTER ASCII VALUE TO DISPLAY:” ACCEPT FIELD-1. DISPLAY CONVERT-FIELD. STOP RUN.

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