TAL Programmer's Guide

Accessing Structure Items
Using Structures
8–40 096254 Tandem Computers Incorporated
Copying Structure Occurrences Within a Structure
To copy occurrences within a structure, specify in a move statement:
The same structure for destination and source
The FOR clause including the ELEMENTS qualifier
For example, you can copy the data in each occurrence of a structure one occurrence to
the right, beginning with occurrence [8], thus freeing occurrence [0] for new data.
LITERAL last = 9; !Last occurrence
STRUCT t_struct(
*
); !Template structure
BEGIN
INT i;
INT j;
END;
STRUCT .s_struct (t_struct) [0:last];
!Source and destination structure
PROC k;
BEGIN
s_struct[last] '=:' s_struct[last-1] FOR last ELEMENTS;
!Move nine structure occurrences
END;
Copying Substructure Occurrences Between Structures
To copy occurrences of a substructure between structures, specify in a move statement:
The fully qualified identifiers of the destination and source substructures
The FOR clause including the ELEMENTS qualifier
You can copy three substructure occurrences from one structure to another as follows:
LITERAL copies = 3; !Number of occurrences
STRUCT .s_struct;
BEGIN
STRUCT s_sub[0:copies - 1];
BEGIN !Source S_SUB is in S_STRUCT
INT a;
INT b;
END;
END;
STRUCT .d_struct (s_struct);
!Destination S_SUB is in D_STRUCT
PROC m;
BEGIN
d_struct.s_sub ':=' s_struct.s_sub FOR copies ELEMENTS;
!Byte move of three
END; ! substructure occurrences