Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 84

Advertising
background image

6Ć44

The number of variables in the READ statement does not have to

match the number of expressions in a specific DATA statement.

BASIC will simply go to the next sequential DATA statement in the

program to acquire the value. The variable type and expression

must match.
A READ statement is not legal without at least one DATA statement.

However, you can have more than one DATA statement as long as

there is one READ statement in the program:

10 READ A,B,C,D,E,F

20...

30...

40...

50 DATA 17,25,30

60 DATA 43,76,29

A READ statement can be placed anywhere in a multiĆstatement

line. A DATA statement, however, must be the only statement on a

line.
If you build your READ statement with more variables than you

include in the data block, the system will print an error message

when it attempts to access the next DATA expression and finds one

is not there.
The following is an example of a READ and DATA sequence:

10 READ A%,B,C1!,D2%,E4@,E6$,Z$

20 DATA 2,32.9987,(83+19),-6, TRUE, CAT",'DOG'

30 PRINT A%,B,C1!,D2%,E4@,E6$,Z$

In the example above, BASIC assigns these values:

A% = 2

B = 32.9987

C1! =102

D2% =-6

E4@ = TRUE

E6$ = CAT

Z$ = DOG

READ and DATA are useful to initialize the values of variables and

arrays at the beginning of a program. To do this, place READ

statements at the beginning of the program. You can put the DATA

statements anywhere in the program. It is often useful to put them all

at the end of the program just before the END statement. See also

the RESTORE statement.

6.8.10

RESTORE Statement

The RESTORE statement is used when reading from a DATA

statement more than once. When you READ data from a series of

DATA statements, BASIC advances an internal pointer to the next

item in the data list every time a READ is done. Once you have read

all the items in the data list, this internal pointer points to the end of

the data list. If you want to read starting with the first DATA

statement, the RESTORE statement tells BASIC to reset its pointer to

the beginning of the DATA statements. The RESTORE statement has

the format:

RESTORE

or

RESTORE line_number(expression)

Advertising
This manual is related to the following products: