pTAL Reference Manual (H06.03+)
Arrays
HP pTAL Reference Manual—523746-005
8-7
Declaring Read-Only Arrays
initialization
is a constant list to assign to the array elements. You must initialize read-only
arrays when you declare them. (Constant lists are described in Section 3, Data
Representation.)
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.
The compiler reports a warning if a read-only array declaration specifies an indirection
symbol (see Table 2-7, Indirection Symbols, on page 2-7).
You must initialize read-only arrays.
UNSIGNED read-only arrays are not allowed, because they cannot be initialized.
If you declare a read-only array in a RESIDENT procedure, the array is also resident in
main memory.
The linker links each global read-only array into any code segment containing a
procedure that references the array.
You can access read-only arrays as you access any other array, except that:
•
You cannot modify a read-only array; that is, you cannot specify a read-only array
on the left side of an assignment or move operator.
•
You cannot specify a read-only array on the left side of a group comparison
expression.
•
In a SCAN or RSCAN statement, you cannot use next-addr to read the last
character of a string. You can use next-addr to compute the length of the string.
Example 8-7. Read-Only Array Declaration With Indirection Symbol
PROC p;
BEGIN
INT i = 'P' := [2,3,4]; ! OK
INT .j = 'P' := [5,6,7]; ! Compiler reports a warning
STRING k = 'P' := ["abc"]; ! OK
STRING .l = 'P' := ["ccc"]; ! Compiler reports a warning
END;
Example 8-8. Declaring and Initializing a Read-Only Array
STRING prompt = 'P' := ["Enter Character: ", 0];
INT error = 'P' := ["INCORRECT INPUT"];










