Read – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 183

Advertising
background image

Chapter
Statements

11

11 -31

Use the READ statement to retrieve the expressions that you specified in
the DATA statement (page 11 -6) and assign the value of the expression to
the variable in the READ statement. The READ statement is always
followed by one or more variables. If more than one variable follows a
READ statement, separate them by a comma.

Every time a READ statement is encountered the next consecutive
expression in the DATA statement is evaluated and assigned to the variable
in the READ statement. You can place DATA statements anywhere within
a program. They are not executed and do not cause an error.
DATA statements are chained together and appear as one large DATA
statement. If at anytime all the data is read and you execute another READ
statement, the program terminates and the message

ERROR: NO DATA –

IN LINE XX

prints to the console device.

See also the DATA (page 11 -6) and RESTORE (page 11 -32) statements.

Syntax

READ

Example

>1 REM EXAMPLE PROGRAM

>10 FOR I = 1 TO 3

>20 READ A,C

>30 PRINT A,C

>40 NEXT I

>50 RESTORE

>60 READ A,C

>70 PRINT A,C

>80 DATA 10,20,10/2,20/2,SIN(PI),COS(PI)

READY

>RUN

10 20

5 10

0 –1

10 20

READY

>

READ

Advertising