TAL Programmer's Guide
Using Structure Pointers
Using Pointers
096254 Tandem Computers Incorporated 9–19
Copying Structure Occurrences
To copy structure occurrences from one location to another, use unqualified identifiers
of structure pointers such as STRUCT_PTR1 and STRUCT_PTR2 in move statements:
STRUCT .old_record[0:2]; !Declare OLD_RECORD
BEGIN
STRING name[0:31];
INT salary;
END;
STRUCT .new_record (old_record) [0:2];
!Declare NEW_RECORD
INT .struct_ptr1 (old_record) := @old_record;
!Declare STRUCT_PTR1;
! initialize it with
! address of OLD_RECORD
INT .struct_ptr2 (new_record) := @new_record;
!Declare STRUCT_PTR2;
! initialize it with
! address of NEW_RECORD
struct_ptr2 ':=' struct_ptr1 FOR 3 ELEMENTS;
!Move statement copies data
! from OLD_RECORD to NEW_RECORD
Accessing STRING Items in Structures
A STRING structure pointer can access the following structure items only—a
substructure, a STRING simple variable, or a STRING array—located in the lower
32K-word area of the user data segment.
To enable a STRING structure pointer to access a STRING structure item, you must
convert the word address of the structure to a byte address before assigning the
address to the pointer:
STRUCT .astruct[0:1];
BEGIN
STRING s1;
STRING s2;
STRING s3;
END;
STRING .ptr (astruct) := @astruct[1] '<<' 1;
!Initialize PTR with converted
! byte address of ASTRUCT[1]
ptr.s2 := %4; !Access STRING structure item