From BR Wiki
Jump to navigation Jump to search

The Data (DA) statement provides a method for initializing data in a program. Constants in a DATA statement are stored in an internal list, which is used by READ statements to assign values to variables.

Comments and Examples

The distinction between uppercase and lowercase is preserved in DATA statements. In the following example, the data in lines 120 and 130 ("Lewisburg" and "Williamsport") would be read into the array CITY$ with lowercase characters, just as they appear in the program line:

00100 DIM Zip(100), CITY$(100)
00120 DATA 17837, Lewisburg
00130 DATA 17701, Williamsport
00150 FOR I=1 TO NZIPS
00160 READ Zip(I), CITY$(I)
00170 NEXT I

The following sample program would print 5200, -520 and 0.0005:

00010 DATA 5.2E3, -5.2e+2, +5e-4
00020 READ A, B, C
00030 PRINT A, B, C


DATA {"<string constant>"|<numeric constant>}[,...] 


At least one "numeric constant" or "string-constant" is required. Numeric constants may include exponents. String and numeric constants may be intermixed. Multiple constants must be separated by commas.

Technical Considerations

1.) String constant that contain commas must be placed in quotation marks.
2.) A DATA statement may not have comments at the end of the line. If comments are present, the system assumes that they are part of the last constant on that line.
3.) Other statements are not permitted on the same line as a DATA statement.
4.) See the READ data and RESTORE data statements for more information.

Use with MAT

DATA is commonly usd to assign numeric or character values into arrays, as seen in the following example:

00030 dim Headings$(10), Widths(10), Forms$(10), Answers$(6)*30,Ordered(3), Head
00040     data "First Name","Last Name","Address","City","State","Zip Code","Shipping","Item 1","Item 2","Item 3"
00050     read Mat Headings$
00060     data 10,10,10,10,4,9,3,3,3,3
00070     read Mat Widths