TAL Programmer's Guide
Copying Data Into Arrays
Using Arrays
7–14 096254 Tandem Computers Incorporated
Copying Data
Into Arrays
To copy data to multiple array elements, use the move statement. You can, for
example, copy:
A constant list into an array
Data between arrays
Data within an array
Copying a Constant
List Into an Array
To copy a constant list into an array, specify the destination array and the constant list in
a move statement. You can copy the source data from left to right or from right to left.
Copying Left to Right
To start copying from the leftmost item of the source data, use the left-to-right move
operator (':='). For example, you can start copying from the leftmost character in a
source character string such as "A ... Z." In this case, you copy "A" into element [0] of
the destination array, then "B" into element [1], and so on through element [25]:
STRING .alpha_array[0:25]; !Declare 26-element array
alpha_array[0] ':=' ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"];
!Copy "A" through "Z" into
! ALPHA_ARRAY[0] through [25]
Copying Right to Left
To start copying from the rightmost item of the source data, use the right-to-left move
operator ('=:'). For example, you can start copying from the rightmost constant of a
constant list such as [1, 2, 3, 4]. In this case, you copy the constant 4 into element [3] of
the destination array, the constant 3 into element [2], and so on through element [0]:
INT num_array[0:3]; !Declare 4-element array
num_array[3] '=:' [1, 2, 3, 4]; !Copy 4 through 1 into
! NUM_ARRAY[3] through [0]
Using Repetition Factors
To repeat the same value in consecutive elements of the destination array, specify a
repetition factor followed by a multiplication operator (*) and the value to repeat. For
example, you can copy a zero into all elements of the destination array:
LITERAL len = 100; !Specify repetition factor
INT .an_array[0:len - 1]; !Declare 100-element array
an_array[0] ':=' len * [0]; !Copy a zero into all
! elements of AN_ARRAY