READ
Syntax
READ {constant,} variable_list
Description
Reads data stored in the application with the DATA command. The constant can be used to change the location within the data array that will be read. The elements of the variable_list must be of basic types, numeric, strings or elements of arrays. Each element read, will be filled from a 32bit value in the 4K space used to store the DATA statements. All the DATA statements in the program behave as a single list.
After the last element of a DATA is read, the first element of the following DATA will be read. The RESTORE statement resets the next-element pointer to the start of the DATA. This allows the user to alter the order in which the DATA are READ.
Example
' Create an array of 5 integers and a string to hold the data.
DIM h(4)
DIM hs$(30)
' Set up to loop 5 times (for 5 numbers... check the data)
FOR read_data = 0 TO 4
' Read in an integer.
READ h(read_data)
' Display it.
PRINT "Number"; read_data;" = "; h(read_data)
NEXT
' Spacer.
PRINT
' Read in a string.
READ hs$
' Print it.
PRINT "String = " + hs$
' Await a keypress.
SLEEP
' Exit program.
END
' Block of data.
DATA 3, 234, 4354, 23433, 87643, "Bye!"
Differences from other BASICs
- Most classic BASICs contain this construct
- Does not exist in Visual BASIC
- PBASIC allows modifiers for size. In PBASIC the first element always sets the offset into the data array. This is the case in ARMbasic only if the first element is a constant.