FutureBasic Logo

<<    Index    >> FutureBasic

read   statement



Syntax
read { var | pstr$(addressVar) } [ , { var | pstr$(addressVar) }...]

Description
This statement reads one or more of the items listed in one or more data statements. If you specify var (which must be either a numeric variable or a string variable), the data item's value is stored into var. If you specify pstr$(addressVar), the item is interpreted as a string and its address is stored into addressVar (which must be a long-integer variable or a pointer variable).
Each var or pstr$ that you specify causes one data item to be read. The first time your program executes a read statement, the first item in your program's first data statement is read. Every time a var or pstr$ is encountered in any read statement, the next data item is read, until all items in all your program's data statements have been exhausted. The number of var or pstr$ specifications in a read statement does not need to match the number of items in a data statement; however, the total number of read requests should not exceed the total number of items in all data statements (unless you use the restore statement, which allows you to re-use data from previous data statements).

Example
data 1,2
data 3,4
data 5,6
for i = 1 to 2
read a, b, c
print a, b, c
next

program output:
1 2 3
4 5 6


See also
data; restore