pTAL Reference Manual (H06.08+)

Built-In Routines
HP pTAL Reference Manual523746-006
15-29
$BITOFFSET
$BITOFFSET
$BITOFFSET returns an INT value that is the offset, in bits, of a structure data item
from the address of the zeroth structure occurrence.
variable
is the fully qualified identifier of a structure item.
The zeroth structure occurrence has an offset of 0. For items other than substructure,
simple variable, array, or pointer declared within a structure, $BITOFFSET returns a 0.
When you qualify the identifier of variable, you can use constant indexes but not
variable indexes; for example:
$BITOFFSET (struct1.subst[1].item) !1 is a constant index
To find the offset of an item in a structure, complete the structure before you use
$BITOFFSET.
You can use $BITOFFSET in LITERAL expressions and global initializations, because
it always returns a constant value.
pTAL privileged procedure No
Can be executed only by privileged procedures No
Sets condition code No
Sets $CARRY No
Sets $OVERFLOW No
Example 15-16. $BITOFFSET Routine
STRUCT a;
BEGIN
INT array[0:40];
STRUCT ab[0:9];
BEGIN
UNSIGNED(1) flag;
UNSIGNED(15) offset;
END;
END;
INT c;
c := $BITOFFSET (a.ab[2]); ! Return offset of 3rd occurrence
! of ab
variable
( )
VST075.vsd
$BITOFFSET