Data item list, Read item list – BrightSign HD2000 BrightScript Reference Guide User Manual

Page 18

Advertising
background image

18


DATA item list

Lets you store data inside your program to be accessed by READ statements. The data items will be read
sequentially, starting with the first item in the first DATA statement, and ending with the last item in the last
DATA statement. Items in a DATA list may be string or numeric constants - no expressions are allowed. If
your string values include leading blanks, colons or commas, you must enclose these values in quotes.
It is important that the data types in a DATA statement match up with the variable types in the corresponding
READ statement (unless you use typeOmatic variables). DATA statements may appear anywhere it is
convenient in a program. Generally, they are placed consecutively, but this is not required.

Examples:
READ N1$,N2$,N1,N2
DATA "SMITH, J.R.","WILSON, T.M."
DATA 150,175

READ item list

Instructs the Interpreter to read a value from a DATA statement and assign that value to the specified variable.
The first time a READ is executed, the first value in the first DATA statement will be used; the second time,
the second value in the DATA statement will be read. When all the items in the first DATA statement have
been read, the next READ will use the first value in the second DATA statement; etc. (An Out-of-Data error
occurs if there are more attempts to READ than there are DATA items.) The following program illustrates a
common application for READ/DATA statements.

50 PRINT "NAME","AGE"
100 READ N$
110 IF N$="END" PRINT "END OF LIST":END
120 READ AGE
130 IF AGE < 18 PRINT N$,AGE
140 GOTO100
150 DATA "SMITH, JOHN",30,"ANDERSON,T.M.",20
160 DATA "JONES, BILL", 15,"DOE,SALLY",21
170 DATA "COLLINS,W.P.",17,END

RUN
NAME

AGE

JONES, BILL

15

COLLINS,W.P.

17

END OF LIST

The program locates and prints all the minors' names from the data supplied. Note the use of an END string to
allow READing lists of unknown length.

The same rule regarding commas, colons and leading blanks applies to values input via DATA statements
and INPUT # statements.
READ T$,N$,D$
PRINT T$;N$;D$
DATA "TOTAL IS: ","ONE THOUSAND,TWO HUNDRED "
DATA DOLLARS.

T$ requires quotes because of the colon; N$ requires quotes because of the comma.

Advertising
This manual is related to the following products: