TAL Programmer's Guide
7 Using Arrays
096254 Tandem Computers Incorporated 7–1
An array is a collectively stored set of elements of the same data type. You use arrays
to store constants, especially character strings. You can use the array identifier to
access the elements individually or as a group.
This section describes:
Declaring arrays
Initializing arrays
Allocating storage for arrays
Accessing arrays
Assigning data to arrays
Copying data into arrays
Scanning arrays
Comparing arrays
This section mostly describes arrays located in the user data segment or in an extended
data segment. “Read-only Arrays” at the end of the section briefly discusses arrays
located in a user code segment.
Section 8, “Using Structures,” shows how structures can simulate multidimensional
arrays, arrays of arrays, or arrays of structures.
Declaring Arrays Before processing an array, you must declare it and store data in it. The declaration
associates an identifier with a memory address. It also tells the compiler how much
storage to allocate for the array and the storage area in which to allocate it.
To declare an array, specify:
A data type
An identifier, usually preceded by an indirection symbol (. or .EXT)
Lower and upper bounds—the indexes of the first and last array elements,
specified as INT constant expressions in the range –32,768 through 32,767,
separated by a colon and enclosed in brackets as follows. The upper bound must
be equal to or larger than the lower bound.
[0:5] !Six elements
Here are examples of array bounds you can declare:
STRING a_array[0:2]; !Three-element array
INT b_array[0:19]; !Twenty-element array
UNSIGNED(1) flags[0:15]; !Array of 16 one-bit elements
Specify the data type and identifier using the type and identifier formats described in
Section 5, “Using Expressions.”
The preceding arrays are all direct arrays; that is, declared without an indirection
symbol. Arrays of any data type can be direct. The compiler allocates storage for
direct arrays in the primary areas of the global, local, or sublocal storage areas.