An array declaration describes the form of the array
Example:
-- various constants used in data types max_iarr : constant := 8; -- largest index in int array min_farr : constant := 'a'; -- low index in float array max_farr : constant := 'h'; -- high index in float array -- type declarations subtype STRING8 is STRING (1 .. 8); type int_8_array is array (1 .. max_iarr) of INTEGER; type float_arrays is array (min_farr..max_farr) of FLOAT; type str_arrays is array (-5 .. 2) of STRING8; type small_arrays is array ('a' .. 'c') of FLOAT;Note that the pattern is the same as we saw with records: constants first, then elementary types, then the structured types (in this case array types).
The declaration gives a name to the array type.
Example:
arr1 : int_8_array; arr2 : float_arrays; arr3 : str_arrays;
An array aggregate can be used to list initial values for items in an array variable
Examples:
-- init array coord1 using a positional list coord1 : small_arrays := (1.2, 2.4, 3.6); -- init array coord1 using explicit index references coord2 : small_arrays := ('c'=>3.6, 'b'=>2.4, 'a'=>1.2);
You can specify a default for other items in array that are not explicitly initialised
-- init array coord1 using other coord3 : small_arrays := ('b'=>5.2, others => 0.0);