TAL Reference Manual

Arrays
TAL Reference Manual526371-001
7-4
Examples of Array Declarations
3. These examples declare and initialize arrays using 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
4. This example initializes all arrays except the local extended indirect array:
INT(32) .a[0:1] := [5D, 7D]; !Initialize global array
PROC my_procedure;
BEGIN
STRING .b[0:1] := ["A","B"]; !Initialize local standard
! indirect 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;
5. The following examples show how positive and negative fpoints affect storage and
access of FIXED values. A positive
fpoint specifies the number of decimal places
to the right of the decimal point for storage and access. The system truncates any
value that does not fit:
FIXED(2) x[0:1] := [ 0.64F, 2.348F ];
!Stored as 64 and 234; accessed as 0.64 and 2.34
6. A negative fpoint specifies the number of integer places to the left of the decimal
point to truncate when the value is stored. When you access the value, the system
replaces the truncated digits with zeros:
FIXED(-3) y[0:1] := [ 642913F, 1234F ];
!Stored as 642 and 1; accessed as 642000 and 1000