READ
 
Syntax

READ {constant,} variable_list

variable_list = variable | array_element  | string_element {, variable_list }
Description


Reads data stored by the BASIC application with the DATA command.

The elements of the variable_list must be integer variables, elements of a string, 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.

If the READ is followed by a constant, then the element will be filled from the nth DATA element where n = constant.

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

END


' Block of data.

DATA 3, 234, 4354, 23433, 87643  
Differences from other BASICs

See also