Data, Data -4 dim -4, Purpose – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 80: Syntax, Example

Advertising
background image

Publication 1746-RM001A-US-P

6-4 Assignment Functions

DATA

Purpose

Use the DATA statement to specify the expressions that you can retrieve with a
READ statement. If multiple expressions per line are used, you must separate them
with 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 considered chained
and appear as 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. The module

returns to Command mode.

Syntax

DATA

Example

>LIST

1

REM EXAMPLE PROGRAM

10 DIM A(4)

20 DATA 10,ASC(A),ASC(C),35.627

30 FOR I=0 TO 3

40 READ A(I)

50 NEXT I

60 FOR J=O TO 3

70 PRINT A(J)

80 NEXT J

READY

>RUN

10

65

67

35.627

DIM

Purpose

Use the DIM statement to reserve storage for matrices. The storage area is first
assumed to be zero. Matrices in the BASIC module may have only one dimension
and the size of the dimensioned array may not exceed 254 elements.

IMPORTANT

You cannot use the CHR operator in a DATA statement.

Advertising