NAME

read - read data statements and assign values to variables

SYNOPSIS

read Var[, Var]... 

DESCRIPTION

Read statements assign data statement elements to the Var list in the read statement on a one-to-one basis.  Read statement variables may be of numeric or string type.  One read statement may access one or more data statements sequentially, or several read statements may access the same data statement.  If the number of variables specified in a read statement is less than the number of items in the data statement or statements, the remaining items are available to be read by the next read statement, starting with the first unread item.  If no read follows, the extra data is ignored.  To reread data from any line in the list of data statements, use the restore statement.  Var is a numeric or string variable or array element which is to receive the value read from the data table.  Read statements must always be used together with data statements. 

EXAMPLE

The program
	print "CITY", "STATE", "ZIP"
	read c$, s$, z
	data "CLEVELAND,", OHIO, 44114
	print c$, s$, z
produces
	CITY         STATE       ZIP
	CLEVELAND,   OHIO         44114
This program reads string and numeric data from the data statement in line 30.  Note that quotation marks around OHIO are not needed, because it doesn’t have commas, semicolons, or significant leading or trailing blanks.  However, the quotation marks around "CLEVELAND," are needed because of the comma. 

SEE ALSO

data, restore

DIAGNOSTICS

Values read by a read statement must match the variable types specified or a "Syntax error" will occur. 

If there are more variables in the Var list than remaining elements in the data statements, an "Out of data" error will occur when the attempt is made to read beyond the end of the list of elements in the data statement. 

If the value of some item in the data statement is too large to store in the corresponding variable in the Var list, an "Overflow" error occurs. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber