pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
lower-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth element) of the first array element you want
allocated.
upper-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth element) of the last array element you want
allocated.
For arrays declared outside of structures, upper-bound must be equal to or larger than
lower-bound.
Here are some examples of bounds:
STRING a_array [0:2];
INT b_array [0:19];
UNSIGNED(1) flags [0:15];
initialization
is a constant or a constant list of values to assign to the array elements, beginning with the
lower-bound element. (Constant lists are described in Chapter 3 (page 46).) If you specify
fewer initialization values than the number of elements, the values of uninitialized elements are
undefined. You cannot initialize extended indirect local arrays or UNSIGNED arrays.
Specify initialization values that are appropriate for the data type of the array. For example,
if the decimal setting of an initialization value differs from the fpoint of a FIXED array, the
system scales the initialization value to match the fpoint. If the initialization value is scaled
down, some precision is lost.
Examples:
• Example 42 (page 110)
• Example 43 (page 110)
• Example 44 (page 110)
• Example 45 (page 111)
• Example 46 (page 111)
• Example 47 (page 111)
• Example 48 (page 112)
Example 42 Declaring Arrays With Various Bounds
FIXED .array_a[0:3]; ! Four-element array
INT .array_b[0:49]; ! Fifty-element array
UNSIGNED(1) flags[0:15]; ! Array of 16 one-bit elements
Example 43 Declaring Arrays and Initializing Them With Constants
INT a_array[0:3] := -1; ! Store -1 in element [0];
! values in elements [1:3] are undefined
INT b_array[0:1] := "abcd"; ! Store one character per byte
Example 44 Declaring Arrays and Initializing Them With Constant Lists
INT c_array[0:5] := [1,2,3,4,5,6]; ! Constant list
STRING buffer[0:102] := [ "A constant list can consist ",
"of several character string constants, ",
"one to a line, separated by commas." ];
INT(32) mixed[0:3] := ["abcd", 1D, %B0101011D, %20D]; ! Mixed constant list
LITERAL len = 80; ! Length of array
110 Arrays