TAL Programmer's Guide
Accessing Structure Items
Using Structures
096254 Tandem Computers Incorporated 8–39
Copying Data in Structures You can copy data to structures by using a move statement. For example, you can
copy:
Structure occurrences between structures
Structure occurrences within a structure
Substructure occurrences between structures
Structure items
To start copying from the lower occurrence, use the left-to-right move operator (':=').
To start copying from the upper occurrence, use the right-to-left move operator ('=:').
Copying Structure Occurrences Between Structures
To copy structure occurrences from one structure to another, specify in a move
statement:
A destination structure and a source structure
The FOR clause including the ELEMENTS qualifier
For example, you can copy three occurrences of a source structure to a destination
structure as follows:
LITERAL copies = 3; !Number of occurrences
STRUCT .s_struct[0:copies - 1]; !Source structure
BEGIN
INT a;
INT b;
INT c;
END;
STRUCT .d_struct (s_struct) [0:copies - 1];
!Destination structure
PROC j;
BEGIN
d_struct ':=' s_struct FOR copies ELEMENTS;
!Move statement copies three
END; ! structure occurrences
If you do not specify ELEMENTS, the equivalent move statement is:
d_struct ':=' s_struct FOR copies
* (($LEN(s_struct) + 1) '>>' 1) WORDS;
which is the code that the compiler generates in this case. The standard function $LEN
returns the length in bytes of one occurrence of S_STRUCT.