ProvideX V8.20 > Language Reference > 2. Directives
271
READ DATA Directive
            Read Data from Program
Formats
1. Read Data: READ DATA varlist,...[,ERR=stmtref]
2. Read from String: READ DATA FROM data$ [,fileopt] TO varlist
Where:
data$
Data to be parsed into the varlist. String expression.
Supported file options (see also, File Options, p.808):
fileopt
END=stmtref End-Of-File transfer
ERR=stmtref Error transfer
REC=name$ Record prefix (REC=VIS(string$) can also be used).
SEP=char$ Default separator character to parse data. Hex or ASCII string
value. Dynamic SEP=* separators are not supported. If the READ DATA
statement also contains a REC= clause, the REC= clause must precede the
SEP=clause.
stmtref
Program line number or label to transfer control to.
List of variables to receive the values from the DATA statements.
varlist
Comma-separated numeric and string variables are allowed.
Description
Use the READ DATA directive to read data embedded in a program.
See Also
DATA Define Data Elements, p.62,
RESTORE Reset Program Data Position, p.287,
BEGIN Reset Files and Variables, p.32,
LOAD Read Program into Memory, p.193.
Format 1: Read Data
READ DATA varlist,...[,ERR=stmtref]
Use this format to transfer the values/expressions from data statements in a program to
the variables identified in varlist. When READ DATA is executed, ProvideX evaluates
each expression in the data statements, in order, and places the values into the
corresponding variables defined in your READ DATA directive.
ProvideX increments an internal pointer to the next data expression during the
reading of data$. When the end of a data statement is reached, the next data
statement in the program is used. Use a RESTORE directive to reset the pointer to the
start of the first data statement.
Example 1:
Include the END= or ERR= option, to avoid an Error #2 when the pointer is at
End-of-File.
0010 DATA "Dog","Cat","Pig"
0020 DATA "Pig","Cat","Dog"
0030 READ DATA X$, END=1000