Read – Remote Processing CAMBASIC User Manual

Page 136

Advertising
background image

Comm ands - 103

READ

Statement

SYNTAX:

R E A D variable [, variable ] . . .

PURPOSE:

To re ad values fr om a D ATA statement a nd assign them to variable s. Se e the DA TA state ment.

REMARK S:

A RE AD sta tement m ust always be used in conjunc tion with a D ATA statement. REA D statem ents
assign DATA statement values to variables in the READ statement on a one– to– one basis. READ
statement variables may be numeric or str ing.

A single READ statement may access one or mor e data statements (they will be accessed in order),
or sever al REA D statem ents may a ccess the sam e DA TA state ment. If the numb er of var iables is
fewer than the num ber of ele ments in the D ATA statement(s ), su bsequent R EAD statements w ill
begin reading data at the first unread element. If there are no subsequent REA D statements, the
extra data is ignored.

To reread the DATA statements from the start, use the RESTORE statement. CLEAR also restores
the data pointer.

RELATED:

DATA, RESTORE

EXAMPLE:

10 FOR X = 1 TO 9
20 READ A(X)
30 NEXT
40 DATA 153,124,5432,10,7,812,11
50 DATA 201,332,762,902,0,–34,69875

This program segment READ s the values from the DATA statements into array A. A fter execution
the value of A(1) will be 153, and so on.

ERROR:

< Syntax> – if data type does not match variable type
< Out of D ATA > – if the numb er of RE ADs e xceed the nu mber of data

Advertising