Microsoft KB Archive/43310

File Status Example Uses the Wrong Format for MS(2)

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

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

Summary: The program example on Page 7-20 of the “Microsoft COBOL Compiler Version 3.0: Operating Guide” displays the file status in the wrong format when compiled with the MS(2) directive. The correct format is displayed (“9 nnnn”, where nnnn is error code) when the COMP picture is changed to COMP-0 as shown below.

More information: Two workarounds for this behavior are as follows: 1. Compile without the MS(2) directive. 2. Change the COMP picture to COMP-0 as shown below. Code Example $SET MS(2) ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILE1 ASSIGN “A:TST.FIL” STATUS FILE1-STAT. DATA DIVISION. FILE SECTION. FD FILE1. 01 F1-REC PIC X(80). WORKING-STORAGE SECTION. 01 FILE1-STAT. 02 S1 PIC X. 02 S2 PIC X. 01 STAT-BIN REDEFINES FILE1-STAT PIC 9(4) COMP. * ^^^^ * This needs to be COMP-0 for MS(2) 01 DISPLY-STAT. 02 S1-DISPL PIC X. 02 FILLER PIC X(3). 02 S2-DISPL PIC 9999 USAGE DISPLAY. PROCEDURE DIVISION. START-TEST. OPEN INPUT FILE1. IF S1 NOT = “9” GO TO END-TEST. MOVE S1 TO S1-DISPL. MOVE LOW-VALUES TO S1. MOVE STAT-BIN TO S2-DISPL. DISPLAY DISPLY-STAT. END-TEST. STOP RUN.

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