The read procedure

Description

The read procedure reads values from the file associated with a file variable into one or more variables.

Parameters

  1. The first parameter is optional, and if supplied is a reference to the file variable associated with the file to read from. If this parameter is not supplied then the read procedure reads values from the file associated with input.
  2. The other parameters are references to the variables used to store the values read from the file.

Reading From Text Files

If the read procedure reads values from a text file (i.e. a file associated with a file variable of type text), then the way the values are read is determined by the type of the variable used to store the values.

Reading From Non-Text Files

If the read procedure reads values from a non-text file (i.e. a file associated with a file variable that is not of type text) then the type of the values read from the file is the same as the type of the variables used to store the values, and this type is usually the same as the file type's component type. The values are read from the file and stored in the variables without conversion.

Example

   read(f, x, y, z)     reads three values from the file associated
                          with "f" into "x", "y", and "z".

Portability

Operating Systems: All
Standard Pascal: Yes

Standard Pascal does not support reading from text files into variable of string type.