READ
Reads data from an existing text file opened for reading by the OPEN command.
Syntax:
READ x READ x, y READ x,y,z,a,b,c,q
Discussion:
The file must be already open, see the keyword OPEN for details. Each READ command reads a single line from the file. The first valid data field from this line is placed in the variable first listed. The data from the second field is placed in the second variable listed, if any.
Therefore, the number of variables listed in the read command should match the number of columns in the text file. Numeric data in the file should be delimited by spaces.
The data may be in free-form, and is internally promoted to double precision. In order to use decimal separator currently selected in Windows settings use READ_LOCALE keyword. A maximum of 2000 characters can be read in on any single line. The maximum number of variable arguments is 199; for reading longer lines with more arguments use READNEXT instead. The variables listed must be valid ZPL variable names.
READNEXT does not support array variable names as arguments. The workaround is to read the data into a scalar variable and then set the array variable to the scalar variable value in a subsequent line like this:
READ x data(i, j) = x
Always CLOSE a file after all the data has been read. See the function EOFF.
Example:
PRINT "Reading the double-column file TEST.DAT!" OPEN "C:\DATA\TEST.DAT" READ x1, y1 READ x2, y2 READ x3, y3 CLOSE
Related Functions:
EOFF
Related Keywords:
OPEN, CLOSE, READNEXT, READSKIP, READSTRING, READ_LOCALE
Next: