Name
Read Procedure
Syntax
procedure Read(var F: File; varVariable; ...); procedure Read(var F: TextFile; varVariable; ...); procedure Read(varVariable; ...);
Description
The Read procedure reads data from a binary or
text file. It is not a real procedure.
To read from a typed binary file, the
Variable must be of the same type as the
base type of the file. Delphi reads one record from the file into
Variable and advances the file position in
preparation for reading the next record. If the file is untyped,
Delphi reads as many bytes as specified for the record size when the
file was opened with Reset. You can list more than
one variable as arguments to Read, in which case,
Read will read multiple records and assign each
one to a separate variable.
When reading from a TextFile,
Read performs a formatted read. Delphi reads
characters from the input file and interprets them according to the
type of each Variable.
Read skips over white space characters (blanks,
tabs, and ends of lines) when reading a number, and stops reading
when it gets to another white space character.
When reading strings and characters, Read does not
skip over white space. If Variable is a
long string, Read reads the entire line into the
string, but not the end-of-line characters. If
Variable is a short string,
Read stops at the end of the line or the size of
the string, whichever comes first.
Errors
If the file has not been assigned,
Readreports I/O error 102.If the file is not open for read access,
Readreports ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access