TAL Programmer's Guide

Assigning the Address of Arrays
Using Arrays
096254 Tandem Computers Incorporated 7–13
You can use constants and LITERALs as index values:
LITERAL index = 5; !Declare LITERAL
INT table[0:9]; !Declare array
table[index] := "AB"; !Access sixth element of array
You can use variables as index values:
INT .EXT b[0:10]; !Declare array
INT .c[0:9]; !Declare array
INT(32) x; !Declare variables X, Y, and
INT y; ! Z to use for indexes
INT z;
!Code to manipulate indexes and initialize arrays
b[x] := c[y-z]; !Access array element
Assigning Data
to Array Elements
You can assign data to one array element at a time. For each array element, use a
separate assignment statement:
STRING .an_array[0:4]; !Declare AN_ARRAY
an_array[1] := "Z"; !Assign "Z" to second
! element of AN_ARRAY
You cannot use constant lists in assignment statements (as you can in declarations) to
assign values to multiple array elements. For example, the following initialization of
THIS_ARRAY is equivalent to the three assignment statements applied to
THAT_ARRAY:
INT .this_array[0:2] := ["ABCDEF"];
!Constant list initializes
! all elements of THIS_ARRAY
INT .that_array[0:2];
that_array[0] := "AB"; !Assignment statements assign
that_array[1] := "CD"; ! values to elements of
that_array[2] := "EF"; ! THAT_ARRAY, one at a time
However, you can copy data to multiple array elements by using a move statement,
described in “Copying Data Into Arrays” later in this section.
Assigning the
Address of Arrays
You can assign the address of array elements to other variables. For example, to
assign the address of ARRAY[1] to VAR, prefix the array identifier with the @ operator
in an assignment statement:
INT .array[0:2]; !Declare array
INT var; !Declare simple variable
var := @array[1]; !Assign address of ARRAY[1]
! to VAR