User Guide

Two-Dimensional Arrays
60
Axcess Programming Language
For example:
DEFINE_VARIABLE
NAMES[1Ø][3Ø] (* two-dimensional array *)
PEOPLE[8][2Ø] (* another two-dimensional array *)
ONE_NAME[3Ø] (* one-dimensional array *)
A_VALUE (* single-value variable *)
DEFINE_PROGRAM
A_VALUE = 1Ø (* statement 1 *)
ONE_NAME = 'EMMITT SMITH' (* statement 2 *)
NAMES[1][1] = 6 (* statement 3 *)
NAMES[1][2] = A_VALUE (* statement 4 *)
NAMES[2] = 'TROY AIKMAN' (* statement 5 *)
NAMES[3] = "1,2,ONE_NAME,3" (* statement 6 *)
FIG. 18 shows what the two-dimensional array NAMES will look like after this code is executed.
Each row in the two-dimensional array has a length value like a one-dimensional array. When a
string literal or expression is assigned to a row of a two-dimensional array (as shown in statements
5 and 6 in the above example), that row has its length value set in the same manner as a one-
dimensional array does. The LENGTH_STRING and SET_LENGTH_STRING functions operate
on rows in two-dimensional arrays in the same way as whole one-dimensional arrays. Once the
above example is executed, the LENGTH_STRING function returns the first three rows of
NAMES:
X = LENGTH_STRING (NAMES[1]) (* X will contain Ø *)
X = LENGTH_STRING (NAMES[2]) (* X will contain 11 *)
X = LENGTH_STRING (NAMES[3]) (* X will contain 15 *)
Retrieving values
There are three ways of referencing the contents:
! By cell (single values)
! By row (an array of values)
! As a whole
Single locations (or cells) are retrieved by using two index values. The first index value specifies
the row, the second the location in that row. For example:
A_VALUE = NAMES[3][6]
FIG. 18 The two-dimensional array NAMES after the assignments
In this example, '6', '10', '1', '2', and '3' are decimal values; the letters are ASCII characters.