TAL Programmer's Guide
Using Structure Pointers
Using Pointers
9–20 096254 Tandem Computers Incorporated
In the following example, a STRING structure pointer accesses a substructure in a
structure:
STRUCT name_def(
*
);
BEGIN
STRING first[0:3];
STRING last[0:3];
END;
STRUCT .record;
BEGIN
STRUCT name (name_def); !Declare substructure
INT age;
END;
STRING .my_name(name_def) := @record.name;
!Only allowed for local or
! sublocal structure pointer
my_name ':=' ["DON GOOD"];
Indexing Structure Pointers To access a structure item in a particular structure occurrence, append an index
(enclosed in brackets) to the identifier of a structure pointer. For example, you can
access item B in the fourth occurrence of a structure by indexing as follows:
STRUCT .low[0:5]; !Declare structure LOW
BEGIN ! to have six occurrences
INT a;
INT b;
END;
INT struct_ptr (low) := @low; !Declare STRUCT_PTR; initialize
! it with address of LOW[0]
struct_ptr[3].b := 45; !Access item B in LOW[3]
You can access a nested structure item by appending indexes to the various levels in
the qualified identifier of the structure item. For example, you can access an array
element in a particular structure and substructure occurrence as follows:
struct_ptr[1].my_substruct[0].my_array[4]
Each index represents an offset from the zeroth element of an array or the zeroth
occurrence of a structure or substructure, regardless of the declared lower bound.
For a byte-addressed structure item, the index represents a byte offset. For a word-
addressed structure item, the index represents a word offset.