pTAL Reference Manual (H06.08+)

Arrays
HP pTAL Reference Manual523746-006
8-5
Declaring Arrays
Example 8-3. 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
STRING buffer[0:len - 1] := len * [" "]; ! Repetition factor
FIXED f[0:35] := 3*[2*[1F,2F], 4*[3F,4F]]; ! Repetition factors
LITERAL cr = %15,
lf = %12;
STRING err_msg[0:9] := [cr, lf, "ERROR", cr, lf, 0]; ! Constant list
Example 8-4. Initializing Arrays
INT(32) a[0:1] := [5D, 7D]; ! Initialize global array
PROC my_procedure;
BEGIN
STRING b[0:1] := ["A","B"]; ! Initialize local standard array
FIXED EXT c[0:3]; ! Cannot initialize local
! extended indirect array
SUBPROC my_subproc;
BEGIN
INT d[0:2] := ["Hello!"]; ! Initialize sublocal array
! Lots of code
END;
END;
Example 8-5. Array With Positive fpoint
FIXED(2) x[0:1] := [ 0.64F, 2.348F ];
! Stored as 64 and 234; accessed as 0.64 and 2.34
Example 8-6. Array With Negative fpoint
FIXED(-3) y[0:1] := [ 642913F, 1234F ];
! Stored as 642 and 1; accessed as 642000 and 1000