TAL Programmer's Guide
Copying Data Into Arrays
Using Arrays
096254 Tandem Computers Incorporated 7–15
Copying a Byte Constant Into a STRING Array
To copy a single byte constant into an element of the destination array, enclose the
constant in brackets in the move statement. The destination array must be a STRING
array or have a byte address:
STRING x[0:8]; !Declare STRING array X
x[0] ':=' ["A"]; !Copy a single byte;
! puts "A" in X[0]
If you do not enclose the constant in brackets, you copy a word, doubleword, or
quadrupleword depending on the size of the constant. The following example repeats
the preceding example, substituting an unbracketed constant in the move statement:
STRING x[0:8]; !Declare STRING array X
x[0] ':=' "A"; !Copy a word; put %0 in
! X[0] and "A" in X[1]
Copying Data
Between Arrays
To copy data from one array to another, specify the destination and source arrays in the
move statement and include the FOR clause. In the FOR clause, specify a count
value—an INT arithmetic expression that specifies the number of elements, bytes, or
words you want to copy.
Copying Bytes
To copy bytes regardless of source data type, specify the BYTES keyword in the FOR
clause of the move statement. BYTES copies the number of bytes specified by the count
value. If both source and destination have word addresses, however, BYTES generates a
word copy for (count + 1) / 2 words.
For example, you can copy bytes instead of words from an INT array as follows:
LITERAL length = 70; !Number of array elements
INT .new_array[0:length - 1]; !Destination array
INT .old_array[0:length - 1]; !Source array
INT file_number; !File number
INT byte_count; !Count value (number of
! bytes to copy)
!Lots of code here
CALL READ (file_number, old_array, byte_count);
new_array[0] ':=' old_array[0] FOR byte_count BYTES;
!Copy bytes from OLD_ARRAY
! to NEW_ARRAY