pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

When you declare arrays inside a structure, the following guidelines apply:
You cannot initialize arrays declared in structures. You can assign values to such arrays only
by using assignment statements.
You cannot declare indirect arrays or read-only arrays in structures.
You can specify array bounds of [n : n-1] in structures (for example, [6:5]).
Such an array is called a zero-length array. It is often used to initialize a structure, as in
Example 85 (page 144). This method of initialization allows you to name something with the
same address as the next “thing” in the list without allocating data for it, similar to a union or
equivalence.
Example 84 Arrays Within a Structure
STRUCT record; ! Declare definition structure
BEGIN
STRING name[0:19]; ! Declare arrays within the structure
STRING addr[0:29]; ! layout
INT acct;
END;
Example 85 Using a Zero-Length Array to Initialize a Structure
STRUCT s;
BEGIN
STRING a[0:-1]; ! @a[0] is the same as @b
INT b;
STRUCT t;
BEGIN
...
END;
...
END;
s.a[0] := 0;
s.a[1] := s.a[0] for $LEN(s); ! Very efficient
...
Declaring Substructures
A substructure is a structure embedded within another structure or substructure. You can declare
substructures that have the following characteristics:
Substructures must be directly addressed.
Substructures have byte addresses, not word addresses.
Substructures can be nested to a maximum of 64 levels.
Substructures can have bounds of [n : n-1] (for example, [6:5]).
Topics:
Definition Substructures (page 144)
Referral Substructures (page 146)
Definition Substructures
A definition substructure describes a layout and allocates storage for it.
144 Structures