TAL Programmer's Guide
Copying Data Into Arrays
Using Arrays
096254 Tandem Computers Incorporated 7–17
Copying Data
Within an Array
To copy data within an array, specify the same array for the destination and source
arrays and include the FOR clause in the move statement.
For example, you can free element [0] of a 12-element array by specifying the
following move statement. This move statement first copies element [10] into element
[11], then element [9] into element [10], and so forth. Finally, it copies element [0] into
element [1], thereby freeing element [0] for new data:
LITERAL upper_bound = 11; !Upper bound of array
FIXED .buffer[0:upper_bound]; !12-element array
!Some code here to put values in
! BUFFER[0] through BUFFER[10]
buffer[upper_bound] '=:'
buffer[upper_bound - 1] FOR upper_bound;
!Start copy with BUFFER[10]
! into BUFFER[11]
Using the Next Address The next address (also known as next-addr) is the memory location immediately
following the last item copied. The next address is returned by the move statement.
You can use the next address for various purposes, such as the starting location for a
new group of values.
First declare a simple pointer and then use its identifier (prefixed by @) in the next-
address clause in a move statement. Here is an example of the next-address clause:
–> @next_addr_ptr
For example, you can copy spaces into the first five elements of an array, and then use
the next address as the destination for copying dashes into the next five elements:
LITERAL len = 10; !Length of array
STRING .array[0:len - 1]; !Destination array
STRING .next_addr_ptr; !Simple pointer for
! the next address
array[0] ':=' 5 * [" "] -> @next_addr_ptr;
!Complete first copy
! and capture next address
next_addr_ptr ':=' 5 * ["-"]; !Use next address as start
! of second copy operation