Arrays
DataBasic allows two types of arrays:
-
Dimensioned Array
-
Dynamic Array
Dimensioned Array
A Dimensioned Array is a multi-element variable which specifies a set of locations, each capable of storing a different data value. Dimensioned arrays must be declared before use via a DIM{ENSION} or COMMON statement. Each location, called an element, is accessed by specifying the array name followed by one or two integer numbers in parentheses, which identify the position of the element within the array. For example, ARRAY(5) identifies the fifth element of array (vector) ARRAY. NAMES(1,3) identifies the element in column 1, row 3 of the two-dimensional array (matrix) NAMES.
Dynamic Array
A Dynamic Array is a single string variable which is divided into multiple elements by special delimiter characters within the string, matching the structure of a Reality file item. Three delimiter characters, are used: attribute mark (represented by ^), value mark(represented by ]) and subvalue mark (represented by \). These three characters separate the dynamic array data into attribute elements, value elements and subvalue elements. Each element is accessed by the dynamic array name followed by up to three integer numbers within chevrons and separated by commas which specify the position of an attribute, value and subvalue. For example, ITEM<2,3,1> identifies the first subvalue within the third value within the second attribute of array ITEM.
Further Information
For some additional information about using arrays efficiently, refer to Efficiency Guidelines.