5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable Usage : Array Variables
 
Share this page                  
Array Variables
An array variable is referred to by the syntax:
arrayname(subscript{,subscript})
Syntax Notes:
1. The variable must be subscripted, because only scalar-valued elements (integers, floating-point, and character strings) are legal EQUEL values.
2. When the array is declared, the array bounds specification is not parsed by the EQUEL preprocessor. Consequently, illegal bounds values will be accepted. Also, when an array is referenced, the subscript is not parsed, allowing illegal subscripts to be used. The preprocessor only confirms that an array subscript is used for an array variable. You must make sure that the subscript is legal and that the correct number of indices is usedA character string variable is not an array and cannot be subscripted in order to reference a single character or a slice of the string. For example, if the following variable were declared:
## abc: String(1..3) := "abc";
you could not reference
abc(1)
to access the character "a." To perform such a task, you should declare the variable as an array of three one-character long strings. For example:
## abc: array(1..3) of String(1..1) := ("a","b","c");
Note that variables of the Ada character type can only be declared as a one-dimensional array. When a variable of that type is used, it must not be subscripted. In the following example, the loop variable "i" is used as a subscript and need not be declared to EQUEL, as it is not parsed.
## formnames: array(1..3) of String(1..8);
   ...
 
for i in 1..3 loop
## forminit formnames(i)
   end loop;