pTAL Reference Manual (H06.03+)

Built-In Routines
HP pTAL Reference Manual523746-005
15-70
$OCCURS
Table 15-15. $OCCURS for Structure Arrays and Arrays Within Structures
$OCCURS Argument Example
$OCCURS
Returns
Unindexed structure array or
substructure array
or
an element of a structure array or
substructure array,
or
an array that is a field within a
structure or substructure
STRUCT s [0:9];
BEGIN
STRUCT
BEGIN
INT
END;
END;
$OCCURS (s);
$OCCURS (a[7]);
$OCCURS (a[7].t);
$OCCURS (a[7].t[3]);
$OCCURS (a[7].t[3].i);
$OCCURS (a[7].t[3].i[v]);
10
1
8
1
5
1
Entire structure
or
nonarray field of a structure or
substructure
STRUCT s;
BEGIN
INT f;
END;
$OCCURS (s);
$OCCURS (s.f);
1
1
Structure template STRUCT s;
BEGIN
INT f[0:9];
END;
$OCCURS (s);
$OCCURS (s.f);
$OCCURS (s.f[5]);
Compile-time err
10
1
Example 15-62. $OCCURS Routine With Nonstructure Arrays
PROC p(x, y);
INT x,
.y;
BEGIN
INT a[0:9];
INT i;
INT .r;
i := $OCCURS(a); ! OK: a is an entire array
i := $OCCURS(i); ! OK: $OCCURS returns 1
i := $OCCURS(x); ! OK: $OCCURS returns 1
i := $OCCURS(a[3]); ! WARNING: $OCCURS returns 1
i := $OCCURS(a[i]); ! WARNING: $OCCURS returns 1
i := $OCCURS(r); ! WARNING: $OCCURS returns 1
i := $OCCURS(y); ! WARNING: $OCCURS returns 1
END;