pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
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 45 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 46 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 47 Array With Negative fpoint
FIXED(-3) y[0:1] := [ 642913F, 1234F ];
! Stored as 642 and 1; accessed as 642000 and 1000
Declaring Read-Only Arrays
A read-only array declaration allocates storage for a nonmodifiable array in a user code segment.
Read-only arrays are sometimes referred to as p-relative arrays, because they are addressed using
the program counter (the p register).
type
is any data type described in Declaring Arrays (page 108) except UNSIGNED. The data type
of a read-only array cannot be an address type.
identifier
is the identifier of the read-only array.
range
Declaring Arrays 111