-
Declaration:
- Procedure Rewrite (Var F : Any File Type[; L : Longint]);
-
Description:
- Rewrite opens a file F for writing. F can be any file type. If F is an untyped or typed file,
then it is opened for reading and writing. If F is an untyped file, the record size can be
specified in the optional parameter L. Default a value of 128 is used. if Rewrite finds a file
with the same name as F, this file is truncated to length 0. If it doesn’t find such a file, a
new file is created.
Contrary to Turbo Pascal, Free Pascal opens the file with mode fmoutput. If it should be
opened in fminout mode, an extra call to Reset (558) is needed.
File sharing is not taken into account when calling Rewrite.
-
Errors:
- Depending on the state of the {$I} switch, a runtime error can be generated if there is an
error. In the {$I-} state, use IOResult to check for errors.
-
See also:
- Reset (558), Assign (455), Close (465), Flush (502), Append (452)
Listing: refex/ex52.pp