Microsoft KB Archive/25996

= No EOF (CTRL+Z) Marker Written at End of Sequential File =

Article ID: 25996

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q25996



SUMMARY
Programs compiled in the following Basic products don't add an end-of-file (EOF) marker [chr$(26), or CTRL+Z, or also known as ASCII byte value 26] at the end of output or appended sequential files:

Microsoft QuickBasic version 4.0, 4.0b, and 4.5 for MS-DOS; Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS and OS/2; and Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS and OS/2.

Sequential files created by programs compiled with QuickBasic versions 4.0 and later, Basic Compiler 6.0 and later, and Basic PDS 7.0 and later will correctly read into programs compiled in QuickBasic version 3.0 even though there is no EOF marker, but other non-Basic DOS applications (those that follow the DOS versions 1.x standard for EOF) may generate an &quot;input past end&quot; error looking for the CTRL+Z.

This is not an error in the QuickBasic or compiled Basic software.



MORE INFORMATION
The lack of writing CTRL+Z to mark the end of the file was a deliberate change to allow QuickBasic programs to read files that contain embedded CTRL+Zs. CTRL+Zs can often occur within binary files and screen files saved with the BSAVE command.

The use of CTRL+Z to mark the end of file is a DOS versions 1.x application standard (which was carried over from the CP/M-80 operating system). Applications written for DOS versions 2.x and 3.x standards use the exact number of bytes in the file to determine the end of file, which is a more practical design. This file size is stored for each file in the file allocation table (FAT) on each disk.

You can write your own CTRL+Z to the end of a file by writing a program that opens the file for append and sends a chr$(26) to the file, for example: OPEN &quot;filename&quot; FOR APPEND AS #1 PRINT #1,CHR$(26);  'Must use &quot;;&quot; to prevent writing extra CR+LF CLOSE #1 Note that no version of Basic automatically appends CTRL+Z to the end of files opened for RANDOM or BINARY access.

Additional query words: QuickBas BasicCom 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB25996

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.