pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 285 $OCCURS Routine With Template Structure Arrays
INT i;
STRUCT s(*);
BEGIN
INT f[0:9];
END;
i := $OCCURS(s); ! ERROR: Template structure not OK
i := $OCCURS(s.f); ! OK: f is an array
i := $OCCURS(s.f[5]); ! WARNING: $OCCURS returns 1
$OFFSET
$OFFSET returns an INT value that is the offset, in bytes, of a structure item from the beginning of
the structure.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
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 216-1.
Example 286 $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 287 $OFFSET Routine
STRUCT .tt;
BEGIN
332 Built-In Routines