TAL Programmer's Guide

Declaring Arrays
Using Arrays
096254 Tandem Computers Incorporated 7–3
Initializing Arrays With Constant Lists
A constant list can include the following elements:
Numbers
INT .numbers[0:5] := [1,2,3,4,5,6];
Character strings of up to 127 characters on one line
INT(32) .words[0:3] := ["cats", "dogs", "bats", "cows"];
STRING .buffer[0:102] := [ "A constant list can consist ",
"of several character string constants ",
"one to a line, separated by commas." ];
Repetition factors—INT constants by which to repeat constant lists
INT zeros[0:9] := 10 * [0]; !Repetition factor of 10
You can nest constant lists that include repetition factors. The following example
expands to [1,1,0,0,1,1,0,0,1,1,0,0]:
INT digits[0:11] := [3 * [2 * [1], 2 * [0]]];
LITERALs
LITERAL len = 80;
STRING .buffer[0:len - 1] := len * [" "];
If you specify fewer initialization values than the number of elements (and the values
are appropriate for the data type of the array), the values of uninitialized elements are
undefined:
STRING bean[0:9] := [1,2,3,4]; !Values in BEAN[4:9]
! are undefined
Initializing Arrays With Constants
You can initialize an array with a numeric constant or a character string constant:
INT some_array[0:3] := -1; !Values in SOME_ARRAY[1:3]
! are undefined
INT any_array[0:1] := "abcd"; !Store one character per byte