pTAL Reference Manual (H06.03+)
Built-In Routines
HP pTAL Reference Manual—523746-005
15-72
$OFFSET
variable
is the fully qualified identifier of a structure field.
The compiler reports an error for the following uses of $OFFSET:
•
$OFFSET applied to an UNSIGNED field. Use $BITOFFSET instead of $OFFSET.
•
$OFFSET applied to an item that is not a field in a structure.
•
$OFFSET applied to a structure array whose lower bound is nonzero; however,
$OFFSET applied to a substructure array whose lower bound is nonzero returns
the appropriate offset.
•
$OFFSET for which the result would be greater than 2
16
-1.
Example 15-65. $OFFSET Routine
STRUCT a;
BEGIN
INT array[0:40];
STRUCT ab[0:9];
BEGIN
! Lots of declarations
END;
END;
INT c;
! Some code
c := $OFFSET (a.ab[2]); ! Return offset of third
! occurrence of substructure
Example 15-66. $OFFSET Routine
STRUCT .tt;
BEGIN
INT i;
INT(32) d;
STRING s;
END;
STRUCT .st;
BEGIN
INT i;
INT j;
INT .st_ptr(tt); ! Declare structure pointer
END; ! that points to structure tt
INT x;
x := $OFFSET (st.j); ! x gets 2
x := $OFFSET (tt.s); ! x gets 6
x := $OFFSET (st.st_ptr.s); ! x gets 6










