pTAL Conversion Guide

Arrays
pTAL Conversion Guide527302-002
9-3
Nonstring Arrays
Nonstring Arrays
In TAL and pTAL, you can specify an initialization string when you declare an array.
TAL
The number of bits in the initialization string must be less than or equal to the number
of bits in the array. In the preceding example, the initialization string contains 64 bits
(four 16-bit integers). TAL also accepts the following declaration, in which the number
of bits in the initialization string (48) is less than the number of bits in the array (64):
INT .a[0:3] := [0,1,2];
TAL reports a warning if the number of bits in the initialization string is greater than the
number of bits in the array, as in the following example:
INT .a[0:3] := [0,1,2,3,4];
Valid:
int p = 'P' := "abcd";
int q[0:3] = 'P' := "abcdabcd";
string r = 'P' := "abcd";
string s[0:3] = 'P' := "abcd";
string t = 'P' := [1,2,3];
string v = 'P' := [1,2,3,4];
string w[0:3] = 'P' := [1,2,3,4];
Example 9-3. Constant Lists in Nonstring Array Declarations (TAL)
Invalid:
INT .a[0:3] := [0,1,2,3,4]; ! WARNING: string is too long
Valid:
INT .a[0:3] := [0,1,2,3]; ! String is 64 bits
INT .a[0:3] := [0,1,2]; ! String is 48 bits
Example 9-2. Constant Lists in Read-Only Array Declarations
(pTAL) (page2of2)