Microsoft KB Archive/64494

Using VALUE on FD Record and FILE-ID Clause Hangs Machine

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

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

Summary: In Microsoft COBOL versions 3.0 and 3.0a, when describing in the FILE SECTION two or more files of any type, if a file contains a VALUE clause in its FD record description, and a following FD description contains a VALUE OF FILE-ID clause, the machine may hang. Microsoft has confirmed this to be a problem in Microsoft COBOL versions 3.0 and 3.0a for MS-DOS and MS OS/2. This problem has been corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2.

More Information: Using a VALUE clause in the FD of a FILE SECTION is not in accordance with the ANSI standard and therefore should not be used in this manner. A VALUE clause should appear only in the WORKING-STORAGE SECTION. The following code example demonstrates this problem. The COBOL compiler fails to flag the error, and when the executable is run, the program hangs (note that the program does not have to execute anything in the PROCEDURE DIVISION to hang). No compiler directives are needed to reproduce the error.

Code Example
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT A          ASSIGN TO DISK 'A.DAT'. SELECT B          ASSIGN TO DISK. DATA DIVISION. FILE SECTION. FD A. * Value clause should not appear here: 01 A-REC                PIC X VALUE &quot;A&quot;. FD B    VALUE OF FILE-ID IS 'B.DAT'. 01 B-REC                PIC X.   PROCEDURE DIVISION. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.