Show: Delphi C++
Display Preferences

System.Read

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Read(var F: File; V1; [ ..., VN]);

Properties

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

Description

Reads data from a file.

The Read procedure can be used in Delphi code in the following ways:

  • For typed files, it reads a file component into a variable.
  • For text files, it reads one or more values into one or more variables.

The syntax shown here for Read demonstrates that the procedure can take a variable number of arguments.

Read reads all characters up to, but not including, the next end-of-line marker or until Eof(F) becomes true; it does not skip to the next line after reading. If the resulting string is longer than the maximum length of the string variable, it is truncated.

After the first Read, each subsequent Read sees the end-of-line marker and returns a zero-length string.

Use multiple Readln calls to read successive string values.

When the extended syntax is enabled, Read can read null-terminated strings into zero-based character arrays.

Read reads one character from the file and assigns it to the variable. If CRLF mode is enabled and Eof(F) was true before Read was executed, the value Chr(26) (a Ctrl-Z character) is assigned to the variable. (To enable CRLF mode, use SetLineBreakStyle.)

Read skips any blanks, tabs, or end-of-line markers preceding the numeric string.

If the numeric string does not conform to the expected format, an I/O error occurs; otherwise, the value is assigned to the variable.

The next Read starts with the blank, tab, or end-of-line marker that terminated the numeric string.

See Also

Code Examples

Personal tools
RAD Studio 10.2 Tokyo
In Other Languages
Previous Versions
Assistance