The Input subroutines allow you to read the contents of a file. The four Input subroutines are ReadNext( ), ReadNextRecord( ), ReadLineNumber( ), and ReadRecordAtLine( ). Their use depends on whether the lines of the file will be read sequentially or randomly, and where the lines will be stored in a single variable or in a record consisting of several variables. Only one line at a time is read in.
Input Subroutine |
Input Method |
Output Format |
ReadNext( ) |
Sequential |
Variable |
ReadNextRecord( ) |
Sequential |
Record |
ReadLineNumber( ) |
Random |
Variable |
ReadRecordAtLine( ) |
Random |
Record |
Each subroutine is defined in the include file (FILEIO.INC).
All Input subroutines keep track of where the next line of the file begins, so ReadNext( ) and ReadNextRecord( ) can be called at any time, provided there are still lines in the file to be read. ReadLineNumber( ) and ReadRecordAtLine( ) find the requested line, if it is in the file, according to its position from the beginning of the file. For example, if you specify a LINE_NUMBER of 3, the third line in the file will be read, etc.