Data structures

RFO-BASIC! provides scalar (single-element) and array variables of both numeric and string types. It also provides data structures for more complex needs. The four types of data structure are:
 * Lists, which are comparable to arrays.
 * Stacks, which are last-in-first-out structures.
 * Queues, which are first-in-first-out structures.
 * Bundles, which are lists of numeric and string items identified by tags.

The BASIC program deals with data structures using a numeric index, just as it deals with files. When a BASIC statement creates a data structure, BASIC assigns it an index and the statement returns the data structure's index. The program must use the same index to refer to the data structure. (Many of BASIC's other features create data structures to which the BASIC program refers with a number. These include bitmaps, items in the graphics Display List, audio files, and SoundPool entries.)

The index is a number that you use to refer to a data structure. You can compare two indexes to see if they refer to the same data structure. However, you should not modify any index, such as subtracting 1 from it to gain access to a data structure created previously. BASIC makes no guarantees about the value of any index except that you can continue to use it to refer to the associated data structure.

The size of these data structures is unlimited except by the total amount of memory available to the program.

All data structures are destroyed when the BASIC program ends, and their information is not available if the same program runs again. For permanent storage of information, BASIC programs can use files, which reside on the Android device's internal storage device or on the SD card, or can use SQL to put the information in a database.

User-defined functions, which generally cannot modify their parameters nor return information to their callers except as a single return value, can communicate with the rest of the program using data structures. For example, a BASIC program could call a user-defined function and pass it the index of a stack of strings. The function — without modifying that index — could use it to put any number of strings onto the stack for use elsewhere in the program.