EGL Reference Guide for iSeries

Examples with a multidimension array

Let's assume that the array myArray01D is substructured to an array of three characters:

  structureItem name="myArray01D" occurs=3 length=3
    structureItem name="myArray02D" occurs=3 length=1

In this example, myArray01D is a one-dimensional array, with each element containing a string that is substructured to an array of three characters. myArray02D is a two-dimensional array, with each element (such as myArray02D[1,1]) containing a single character.

If the content of myArray01D is "ABC", "DEF", and "GHI", the content of myArray02D is as follows:

  "A"   "B"   "C"
  "D"   "E"   "F"
  "G"   "H"   "I"

The next table shows the effect of the operator in.

Logical expression Value of expression Value of sysVar. ArrayIndex Comment
"DEF" in myArray01D true 2 A reference to a one-dimensional array does not require a subscript; by default, the search begins at the first element
"C" in myArray02D[1] -- -- The expression is invalid because a reference to a multidimensional array must include a subscript for each dimension
"I" in myArray02D[3,2] true 3 Search begins at the third row, second element
"G" in myArray02D[3,2] false 0 Search ends at the last element of the row being reviewed
"G" in myArray02D[2,4] false 0 The second subscript is greater than the number of columns available to search


Related tasks
Syntax diagram


Related reference
Arrays
Logical expressions
Operators and precedence
sysVar.arrayIndex


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]