pTAL Reference Manual (H06.08+)

Arrays
HP pTAL Reference Manual523746-006
8-4
Declaring Arrays
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 Section 3, Data
Representation.) 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 8-1, Declaring Arrays With Various Bounds, on page 8-4
Example 8-2, Declaring Arrays and Initializing Them With Constants, on page 8-4
Example 8-3, Declaring Arrays and Initializing Them With Constant Lists, on
page 8-5
Example 8-4, Initializing Arrays, on page 8-5
Example 8-5, Array With Positive fpoint, on page 8-5
Example 8-6, Array With Negative fpoint, on page 8-5
Example 8-7, Read-Only Array Declaration With Indirection Symbol, on page 8-7
Example 8-1. 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 8-2. 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