TAL Reference Manual

Standard Functions
TAL Reference Manual526371-001
14-30
Examples of $OCCURS Function
Examples of $OCCURS Function
1. In this example, $OCCURS returns the number of occurrences of a structure,
which is 6:
INT index;
STRUCT .job_data[0:5]; !Declare structure
BEGIN
INT i1;
STRING s1;
END;
FOR index := 0 TO $OCCURS (job_data) - 1 DO ... ;
!Return 6, the number of
! structure occurrences
2. In this example, $OCCURS returns the number of elements in an array, and $LEN
returns the number of bytes in each element. This example multiplies 3 times 4
(the values returned by $OCCURS and $LEN) and yields the number of bytes in
the entire array:
INT array_length; !Declare variables
INT(32) array[0:2];
array_length := $LEN (array) * $OCCURS (array);
!Return 12, the length of the entire
! array in bytes
$OFFSET Function
The $OFFSET function returns the number of bytes from the address of the zeroth
structure occurrence to a structure data item.
variable
is the fully qualified identifier of a structure data item—a substructure, simple
variable, array, simple pointer, or structure pointer declared within a structure
$OFFSET ( variable
)
VST1433.vsd