Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Rewrite Procedure
◄Summary► ◄Details► ◄Example► ◄Back►
Arguments
file_variable Typed, untyped, or text file; already assigned
size Optional; block size for data transfers; applies
only to untyped files (default is 128 bytes)
Description:
The Rewrite procedure creates a new file or overwrites an existing
file. The name of the file is the device or file name associated
with file_variable. Use the Assign procedure to associate a device
or file name with file_variable. Rewrite moves the current
position of the opened file to the first position in the empty
file.
If the file already exists, the contents of the file are deleted.
If the file is already open, it is deleted, and a new one by that
name is created.
A file can be text, typed, or untyped. Rewrite operates according
to the type of file:
Opens a text file for writing only. After Rewrite, the Eof
function returns True. By default, Rewrite associates a
128-byte buffer with a text file. Use the SetTextBuf procedure
to specify a buffer of a different size.
Opens typed and untyped files for reading and writing.
Sets the block size to a specified size in untyped files,
through the size argument. The BlockRead and BlockWrite
procedures transfer data in blocks of a specific size. The
FileSize function returns the size of a file in blocks. An
untyped file has a default block size of 128 bytes. On many
machines the most efficient size is a multiple of 512 bytes.
Opens a device for output.
To refer to the standard file Output (file handle 1), call Assign
with a null string, then Rewrite the file.
If file_variable has not been assigned to an external file name,
an I/O error occurs.
To prevent a program from halting with a run-time error when an
I/O error occurs, turn off I/O checking with {$I-} and check the
return value of the IOResult function.