HP Pascal/iX Reference Manual (31502-90022)

10- 20
rewrite
Usage
rewrite
(f)
rewrite
(f, s)
rewrite
(f, s, t)
Parameters
f
A file variable that may not be omitted.
s
The name of a physical file the system associates with
f
.
t
May be a string or PAC expression whose value is implementation
dependent.
Description
The procedure rewrite
(f)
opens the file
f
in the output state and places
the current position at the first component. The system discards any
previously existing components of
f
. The function eof
(f)
returns true
and the buffer variable
f
^ is undefined. The file
f
may now be written
sequentially.
If
f
is already open at the time rewrite is called, the system closes it
automatically, flushes the buffers, and then reopens it, losing the
contents of the file. If
s
is specified, the system closes any physical
file previously associated with
f
and associates
s
with
f
.
When
f
does not appear as a program parameter and
s
is not specified, the
system maintains any previous association of a physical file with
f
. If
there is no such association, it opens a temporary, nameless file. This
file cannot be saved. It becomes inaccessible after the process
terminates or the physical-to-logical file association changes. For more
information, see the
HP Pascal/iX Programmer's Guide
or the
HP
Pascal/HP-UX Programmer's Guide
, depending on your implementation.
Example
rewrite(file)
rewrite(file,file_name)
rewrite(file,file_name,opt_str)
Illustration
Suppose examp_file is a closed file of char with three components. To
discard these components and write sequentially to examp_file, rewrite is
called.