TAL Programmer's Guide

Copying Data Into Arrays
Using Arrays
7–16 096254 Tandem Computers Incorporated
Copying Words
To copy words regardless of source data type, specify the WORDS keyword in the
FOR clause. WORDS generates a word copy for the number of words specified by the
count value.
For example, to copy words instead of doublewords from an INT(32) source array,
multiply LENGTH by 2 and include the WORDS keyword:
LITERAL length = 12; !Count value (number of
! words to copy)
INT(32) .new_array[0:length - 1];!Destination
INT(32) .old_array[0:length - 1];!Source
!Some code here to put values in OLD_ARRAY
new_array[0] ':=' old_array[0] FOR 2 * length WORDS;
!Copy 24 words from
! OLD_ARRAY to NEW_ARRAY
Copying Elements
To copy elements based on the data type of the source array, you can specify the
ELEMENTS keyword. For example, you can copy doubleword values from an
INT(32) source array into the destination array as follows:
LITERAL length = 12; !Count value (number of
! elements to copy)
INT(32) .new_array[0:length - 1];!Destination
INT(32) .old_array[0:length - 1];!Source
!Some code here to put values in OLD_ARRAY
new_array[0] ':=' old_array[0] FOR length ELEMENTS;
!Copy 12 doublewords from
! OLD_ARRAY to NEW_ARRAY
When you copy array elements, the ELEMENTS keyword is optional but provides
clearer source code. When you copy structure occurrences, the ELEMENTS keyword
is required, as described in Section 8, “Using Structures.”