beautypg.com

Statements: data – read – restore – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 55

background image

Operating Functions

Chapter 5

5–18

Mode: RUN
Type: Assignment

DATA

DATA specifies expressions that you can retrieve using a READ statement.
If multiple expressions per line are used, you MUST separate them with a
comma.

Example:

u10 DATA 10,ASC(A), ASC(B), 35.627

Important: You cannot

use the CHR() operator in a DATA statement.

READ

READ retrieves the expressions

that are specified in the DATA statement

and assigns

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, they

are separated by a comma.

RESTORE

RESTORE “resets”

the internal read pointer to the beginning of the

data so that it may be read again.

Example:

u10 FOR I=1 TO 3

u20 READ A,B

u30 PRINT A,B

u40 NEXT I

u50 RESTORE

u60 READ A,B

u70 PRINT A,B

u80 DATA 10,20, 10/2,20/2,SIN(PI),COS(PI)

uRUN

10

20

5

10

0

–1

10

20

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 considered to be chained

together and appear

to be one large DATA statement. If at anytime all the data is read and
another READ statement is executed,

the program terminates and the

message ERROR: NO

DATA – IN LINE XX prints to the console

device.

5.4.6
Statements: DATA –
READ – RESTORE