Language Reference


INFILE Statement

  • INFILE operand <options>;

The INFILE statement opens an external file for input or, if the file is already open, makes it the current input file. A subsequent INPUT statement reads from the specified file.

The arguments to the INFILE statement are as follows:

operand

is either a predefined filename or a quoted string that contains in parentheses the filename or character expression that refers to the pathname.

options

are explained in the following list.

The valid values for the options argument are as follows:

LENGTH=variable

specifies a variable into which the length of a record is stored.

RECFM=N

specifies that the file be read in as a pure binary file rather than as a file with record separator characters. To do this, you must use the byte operand (<) in the INPUT statement to get new records rather than use separate input statements or the new line (/) operator.

The following keywords control how a program behaves when an INPUT statement tries to read past the end of a record. The default behavior is STOPOVER.

FLOWOVER

enables the INPUT statement to go to the next record to obtain values for the variables.

MISSOVER

tolerates attempted reading past the end of the record by assigning missing values to variables read past the end of the record.

STOPOVER

treats going past the end of a record as an error condition, which triggers an end-of-file condition.

Several examples of INFILE statements follow:

filename in1 "student.dat";        /* specify filename IN1   */
infile in1;                        /* infile pathname        */

infile "student.dat";              /* path by quoted literal */

infile "student.dat" missover;     /* use missover option    */

See ChapterĀ 8 for further information.