System.Reset

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Reset(var F: File); overload;
procedure Reset(var F: File; RecSize: Integer); overload;

Properties

Type Visibility Source Unit Parent
procedure public System.pas System System

Description

Opens an existing file.

In Delphi code, Reset opens the existing external file with the name assigned to F using the mode specified by the global FileMode variable. An error results if no existing external file of the given name exists or if the file cannot be opened with the current file mode. If F is already open, it is first closed and then reopened. The current file position is set to the beginning of the file.

Warning: The default value of FileMode is 2 (Read/Write access). If this is not changed to a read-only file mode before calling Reset, attempts to open read-only files fail.

F is a variable of any file type associated with an external file using AssignFile. RecSize is an optional expression that can be specified only if F is an untyped file. If F is an untyped file, RecSize specifies the record size to be used in data transfers. If RecSize is omitted, a default record size of 128 bytes is assumed. If RecSize is equal to or lower than 0, it causes a 106 I/O Error.

If F is assigned an empty name such as AssignFile(F, ''), then after the call to Reset, F refers to the standard input file.

If F is a text file, F becomes read-only.

After a call to Reset, Eof(F) is True if the file is empty; otherwise, Eof(F) is False.

If any I/O error happens, Reset closes the file. You do not need to call CloseFile.

Note: {$I+} handles run-time errors using exceptions. When using {$I-}, use IOResult to check for I/O errors.

See Also


Code Examples