TAL Programmer's Guide
Accessing Arrays
Using Arrays
7–12 096254 Tandem Computers Incorporated
Accessing Arrays After you declare an array, you can access its elements by using the array identifier in
statements, regardless of addressing mode. For example, you can declare a direct
array, a standard indirect array, and an extended indirect array, and then access each
by its identifier:
INT dir_array[0:2]; !Declare direct array
INT .std_array[0:2]; !Declare standard indirect array
INT .EXT ext_array[0:2]; !Declare extended indirect array
dir_array[2] := 5; !Access third element of each
std_array[2] := 5; ! array by using its identifier in
ext_array[2] := 5; ! an assignment statement
Indexing Arrays To access an array element, you append an index such as [5] to the array identifier.
You can access element [0] of any array (except type UNSIGNED) by specifying the
array identifier with no index. Thus, the references BUFFER and BUFFER[0] are
equivalent. To access an UNSIGNED array, however, you must always append an
index:
UNSIGNED(8) uns_array[0:2];
uns_array[0] := 0; !UNS_ARRAY requires index
Index Values
The index value represents the array element you want to access, relative to the zeroth
element. For example, to access the third element, specify an index of [2]:
INT array[0:2];
array[2] := 5; !Access third element of array
For the index value, use a signed arithmetic expression:
For standard addressing, use a signed INT expression, which has a range of
–32,768 through 32,767.
For extended addressing, use either a signed INT expression or an INT(32)
expression, which has a range of –2,147,483,648 through 2,147,483,647.