pTAL Reference Manual (H06.03+)

Pointers
HP pTAL Reference Manual523746-005
10-18
Initializing Structure Pointers
A standard STRING structure pointer can access only these structure items:
Substructure
STRING simple variable
STRING array
The last declaration in Example 10-15 on page 10-18 shows a STRING structure
pointer initialized with the converted byte address of a substructure.
Example 10-16 on page 10-18 shows another way to access a STRING item in a
structure. You can convert the word address of the structure to a byte address when
you initialize the STRING structure pointer and then access the STRING item in a
statement.
Example 10-15. Declaring and Initializing a Structure Pointer, Using $OFFSET
STRUCT t (
*
); ! Template structure
BEGIN
INT k;
END;
STRUCT .st; ! Definition structure
BEGIN
INT j;
STRUCT ss (t);
END;
INT .ip := @st '+' $OFFSET (st.j) '>>' 1; ! Simple pointer
INT .stp (t) := @st '+' $OFFSET (st.ss) '>>' 1;
! INT structure pointer
STRING .sstp (t) := @st '<<' 1 '+' $OFFSET (st.ss);
! STRING structure pointer
Example 10-16. Declaring and Initializing a STRING Structure Pointer
STRUCT .astruct[0:1];
BEGIN
STRING s1;
STRING s2;
STRING s3;
END;
STRING .ptr (astruct) := @astruct[1] '<<' 1; ! STRING ptr
! initialized
! with converted
! byte address of
! astruct[1]
ptr.s2 := %4; ! Access STRING structure item