LOAD DATA

BASin

LOAD DATA

Statement/Command

LOAD DATA is used to load arrays from files. The arrays are stored using SAVE DATA.

How to use LOAD DATA

LOAD DATA may be used to form a statement or as a direct command. LOAD is first followed by a filename, which is a string value, followed by DATA and a letter or a letter and $, and finally by a pair of empty brackets, for example

270 LOAD "numbers" DATA n()
300 LOAD "names" DATA n$()

The filename following LOAD is the name that is given to the array in the file, and it is subject to the same restrictions as program names used with LOAD. The letter or letter$ following DATA is the name to be given to the array in the program when it is loaded and used.

On execution, the BASIC searches for the named array. When found, the message Number array: or Character array: followed by the name appears and the array is loaded. Any array currently in memory having the same letter name (n or n$ above) is deleted, and a new array having this letter name and the values stored in the file is created. Note that with character arrays, any string variable currently in memory having the same letter name is also deleted.

Format

  • LOAD string-expr DATA letter[$]()

See also

Chapter 20.