Arrays

An array is an ordered list of variables of the same type. Arrays of data type boolean, number, float and string are supported. Elements in an array are referenced via an index on the array beginning at one (1). The number of elements in an array must be set explicitly. Multidimensional arrays are not supported.

Example

dcltrans 
  transaction TMain 
  var 
    nNumber : number; 
    bBoolean : boolean; 
    sString : string; 
    aNumberArray :  array [10] of number; 
    aBooleanArray :  array [10] of boolean; 
    aStringArray :  array [5] of string(20); 
  begin 
    nNumber := 5; 
    bBoolean := false; 
    sString := "This is a string"; 
    aNumberArray[1] := 2; 
    aBooleanArray[aNumberArray[1]] := true; 
    aStringArray[nNumber] := simstr; 
  end TMain;

Initialization of arrays

If you initialize an array, you need not specify the size of the array. The size is equivalent to the number of initial values. If an array is initialized and its size is specified, all array items not initialized are set to the null value of the data type of the array.

Example

const 
  cStr := "Paul"; 
  cNumber := 8; 
  cFloat := 2.5 
var 
  aStringArray : array [6] of string(9) init cStr, "Jim", 
  "John", "George", "Ringo", cStr; 
  aNumberArray1 : array of number init cNumber, 1, 2, 3, 4, 5, 6, 7, cNumber; 
  aNumberArray2 : array of number init 1; 
  aNumberArray3 : array [5] of number init 1, 2, 3; 
  aFloatArray : array of float init cFloat, 1.0, 2.0, 3.3, 5.5, 6.6; 
  aBooleanArray : array of boolean init true, false, true;