array-type "{" expr-1 "," ... "," expr-n [ ", .." ] "}"
An array constructor is an array-valued expression. array-type must be a fixed or open array type (see section Array Types). Each expr must be assignable to the element type of A. Thus, multidimensional array constructors are built by nesting array constructors (see tictactoe example below). For fixed array constructors, there must be one expression per slot, with the shortcut that if ", .." is included at the end, the last expression is repeated as many times as is needed to fill out the array.
In some of the examples below, the type of the constant or variable is explicitly specified apart from the constructor. In others, the constructor itself provides the type. Either case is valid.
CONST vowels: ARRAY [1..5] OF CHAR = ARRAY [1..5] OF CHAR{'a','e','i','o','u'}; names = ARRAY [1..10] OF TEXT{"John", "Suzie", "Helen", "", ..}; (* names[4] thru names[10] are set to empty strings *) invalid = ARRAY [1..20] OF INTEGER{5, 10, 15}; (* not enough elements provided *) VAR openarr := ARRAY OF CHAR{'a', 'b', 'c'}; (* invalid: a variable may not be an open array *) vowels2: ARRAY [1..5] OF CHAR := ARRAY OF CHAR{'a','e','i','o','u'}; (* But an open array constructor can be assigned to a fixed array type *) tictactoe := ARRAY [1..3], [1..3] OF CHAR{ ARRAY OF CHAR{' ', ' ', ' '}, ARRAY OF CHAR{' ', ' ', ' '}, ARRAY OF CHAR{' ', ' ', ' '} };
Note: Open array types can be used for procedure parameters.
You can create open arrays at run-time via the NEW call.