read - read data statements and assign values to variables


read Var[, Var]... 


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. 


The program
	print "CITY", "STATE", "ZIP"
	read c$, s$, z
	data "CLEVELAND,", OHIO, 44114
	print c$, s$, z
	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. 


data, restore


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