17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GW-BASIC <strong>User's</strong> Guide<br />

READ Statement<br />

Purpose:<br />

To read values from a DATA statement and assign them to variables.<br />

Syntax:<br />

READ list of variables<br />

Comments:<br />

A READ statement must always be used with a DATA statement.<br />

READ statements assign variables to DATA statement values on a one-to-one basis.<br />

READ statement variables may be numeric or string, and the values read must agree with the<br />

variable types specified. If they do not agree, a "Syntax error" results.<br />

A single READ statement may access one or more DATA statements. They are accessed in order.<br />

Several READ statements may access the same DATA statement.<br />

If the number of variables in list of variables exceeds the number of elements in the DATA<br />

statement(s), an "Out of data" message is printed.<br />

If the number of variables specified is fewer than the number of elements in the DATA statement<br />

(s), subsequent READ statements begin reading data at the first unread element. If there are no<br />

subsequent READ statements, the extra data is ignored.<br />

To reread DATA statements from the start, use the RESTORE statement.<br />

Examples:<br />

.<br />

.<br />

.<br />

80 FOR I=1 TO 10<br />

90 READ A(I)<br />

100 NEXT I<br />

110 DATA 3.08, 5.19, 3.12, 3.98, 4.24<br />

120 DATA 5.08, 5.55, 4.00, 3.16, 3.37<br />

.<br />

.<br />

.<br />

This program segment reads the values from the DATA statements into array A. After execution,<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/READ.html (1 of 2)28/03/2004 21.29.21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!