Microsoft KB Archive/60146

OPEN EXTEND on LINE SEQUENTIAL File Writes After EOF Mark

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

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

Summary: When a LINE SEQUENTIAL file is OPENed for EXTEND with a file containing an end-of-file character (1A hex), information written to the file will be placed after the EOF marker instead of before the EOF marker. To work around this problem, rewrite the file without the EOF marker before the file is OPENed for EXTEND. Microsoft has confirmed this to be a problem with Microsoft COBOL Compiler versions 3.0 and 3.0a for MS-DOS and MS OS/2, and in Microsoft COBOL Professional Development System version 4.0. We are researching this problem and will post new information here as it becomes available.

More Information: The following information, from Page 7-13 of the operating guide for COBOL 3.0 and 3.0a, describes COBOL behavior with LINE SEQUENTIAL files containing an EOF marker: Any single byte 1A hex (CTRL+Z) is used as an unconditional file terminator. A 1A hex character in a file created with this system is treated as a data character since such characters are “escaped” using a null character (see below [see page 7-13 and 7-14]). Reading a 1A hex character in a file not created with this system causes the end-of-file status to be set.

Code Example
The following code example incorrectly writes the input data after the EOF marker in the specified file: ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT TEST-FILE ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD TEST-FILE LABEL RECORDS ARE STANDARD VALUE OF FILE-ID IS “TEST.DAT” DATA RECORD IS TEST-RECORD. 01 TEST-RECORD PIC X(10). PROCEDURE DIVISION. 000-MAIN. OPEN EXTEND TEST-FILE. ACCEPT TEST-RECORD. WRITE TEST-RECORD. CLOSE TEST-FILE. STOP RUN.

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