TAL Programmer's Guide
Using Structure Pointers
Using Pointers
9–22 096254 Tandem Computers Incorporated
The following example shows how you can index a standard structure pointer:
STRUCT .std_struct[0:99]; !Standard indirect structure
BEGIN
INT var; !Simple variable
STRING array[0:25]; !Array
STRUCT substr[0:9]; !Substructure
BEGIN
STRING array[0:25]; !Array
END;
END;
INT index := 5; !Simple variable
PROC x MAIN; !Declare procedure X
BEGIN
INT struct_ptr (std_struct) := @std_struct;
!Declare standard structure pointer
struct_ptr[index].var := 35;
!Access STD_STRUCT[5].VAR
struct_ptr[index+2].array[0] := "A";
!Access STD_STRUCT[7].ARRAY[0]
struct_ptr[index+2].array[25] := "Z";
!Access STD_STRUCT[7].ARRAY[25]
struct_ptr[9*index].substr[index-1].array[index-5] := "a";
!Access
! STD_STRUCT[45].SUBSTR[4].ARRAY[0]
END; !End procedure X
Indexing Extended Structure Pointers
The index for extended structure pointers must be a signed INT or INT(32) arithmetic
expression, depending on the size of the offset of the structure item you want to
access. The offset of a structure item is from the zeroth structure occurrence (not the
current structure occurrence).
C-Series System. If you are writing a program to run on a C-series system, you can
determine whether to use an INT index or an INT(32) index (which is slower) as
follows:
1. Compute the lower and upper byte or word offsets of the structure item whose
structure pointer is being indexed. (A byte-addressed structure item is at a byte
offset. A word-addressed structure item is at a word offset.)
2. If the offsets are inside the signed INT range (–32,768 through 32,767), use an INT
index. Usually, offsets are within the signed INT range.
3. If the offsets are outside the signed INT range, use an INT(32) index. To convert
an INT index to an INT(32) index, use the $DBL function.