TAL Programmer's Guide
Accessing Structure Items
Using Structures
096254 Tandem Computers Incorporated 8–35
Assigning Addresses to
Pointers in Structures
You can assign to pointers the kinds of addresses listed in Tables 8-4 and 8-5 earlier in
this section. To assign an address to a pointer within a structure, specify the fully
qualified pointer identifier in an assignment statement. Prefix the structure identifier
with @. For example, the assignment statement to assign an address to PTR_X
declared in SUBSTRUCT_A in STRUCT_B is:
@struct_b.substruct_a.ptr_x := arith_expression;
In the preceding example, @ applies to PTR_X, the most qualified item. On the left
side of the assignment operator, @ changes the address contained in the pointer, not
the value of the item to which the pointer points.
You can also prefix @ to a variable on the right side of the assignment operator. If the
variable is a pointer, @ returns the address contained in the pointer. If the variable is
not a pointer, @ returns the address of the variable itself.
The following example shows @ used on both sides of the assignment operator. This
example assigns the address of ARRAY to STD_PTR within a structure. Also, the
$XADR function converts the standard address of ARRAY to an extended address,
which is then assigned to an extended simple pointer:
INT .array[0:99]; !Declare ARRAY
STRUCT .st; !Declare ST
BEGIN
INT .std_ptr; !Declare STD_PTR
INT .EXT ext_ptr; !Declare EXT_PTR
END;
PROC e MAIN;
BEGIN
@st.std_ptr := @array[0]; !Assign standard address of
! ARRAY[0] to ST.STD_PTR
@st.ext_ptr := $XADR(array[0]);
!Assign extended address of
END; ! ARRAY[0] to ST.EXT_PTR