Microsoft KB Archive/60145

Screen Accept of S99 SIGN LEADING/TRAILING Rejects Sign

PSS ID Number: Q60145 Article last modified on 04-03-1990

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

Summary: Using the default ADIS configuration (and several other standard ADIS configurations), COBOL does not ACCEPT a negative value in a SCREEN SECTION entry with a SIGN clause without the SEPARATE option. The MS2-2.DOC file documents that the “-” sign should be used instead of the SIGN clause with PIC S99 fields. This information applies to Microsoft COBOL Compiler Versions 3.00 and 3.00a for MS-DOS and MS OS/2.

More information: Negative values are ACCEPTed without the SEPARATE SIGN in the “Microsoft Version 2” ADIS configuration (by using ADISCF). Values are also ACCEPTed correctly when the SEPARATE option is used with SIGN. The following information is listed as the “General Rule” for the SIGN clause on Pages 15-40 of the “Microsoft COBOL Compiler 3.0: Language Reference Manual” for COBOL Versions 3.00 and 3.00a: It is recommended that the SEPARATE option be used when the SIGN clause is specified in a screen description. If the SEPARATE option is not specified, a sign denoted by ‘S’ in a PICTURE clause appears as an overpunch. Because the SEPARATE clause is explicitly recommended, most consistent results can be achieved by using the SEPARATE option with the SIGN clause. The following information (from the MS2-2.DOC file from COBOL 3.00, NOT in the COBOL 3.00a MS2-2.DOC file) describes the behavior and solution to the SCREEN ACCEPTs of SIGNed values: Screen Handling Problem: S9(n) (non-decimal) DISPLAY fields, when ACCEPTed through ADIS, will not let you enter a sign and will always be returned negative. Solution: Change the “S” to a “-” sign, and the sign will be handled correctly. Note: The SIGN clause should not be used with the “-” sign since the minus explicitly shows where the sign should be placed.

Code Example
The following code example accepts signed numerics using several different sign formats (leading, trailing, separate and “-”); it demonstrates the behavior described above: WORKING-STORAGE SECTION. 01 SIGNED-1 PIC S99. 01 SIGNED-2 PIC S99. 01 SIGNED-3 PIC S99. 01 SIGNED-4 PIC S99. 01 SIGNED-5 PIC S99. 01 SIGNED-6 PIC S99. SCREEN SECTION. 01 SIGN-SCREEN. 05 BLANK SCREEN. 05 LINE 1 COLUMN 1 PIC S99 SIGN TRAILING TO SIGNED-1. 05 LINE 2 COLUMN 1 PIC S99 SIGN LEADING TO SIGNED-2. 05 LINE 3 COLUMN 1 PIC S99 SIGN TRAILING SEPARATE TO SIGNED-3. 05 LINE 4 COLUMN 1 PIC S99 SIGN LEADING SEPARATE TO SIGNED-4. 05 LINE 5 COLUMN 1 PIC 99- TO SIGNED-5. 05 LINE 6 COLUMN 1 PIC -99 TO SIGNED-6. PROCEDURE DIVISION. MAIN. DISPLAY SIGN-SCREEN. ACCEPT SIGN-SCREEN. STOP RUN.

Copyright Microsoft Corporation 1990.