The following table shows the effect of the
in operator
when you refer to a character array named
myArray,
defined as follows:
myArray CHAR(1)[3] {"A", "B", "C"};
Table 1. Effects of the in operator| Logical expression |
Value of expression |
Value of sysVar.
ArrayIndex |
Comment |
| "A" in myArray |
true |
1 |
|
| "C" in myArray from 2 |
true |
3 |
Search begins at second element ("B") |
| "A" in myArray from 2 |
false |
0 |
Search begins at second element ("B") |
In the next example, myArray01D is a one-dimensional array of strings,
defined as follows:
myArray01D STRING[] = ["ABC", "DEF", "GHI"];
myArray02D
is a two-dimensional array, with each element (such as myArray02D[1,1])
containing a single character, defined as follows:
myArray02D CHAR(1)[3][3] = [["A", "B", "C"],
["D", "E", "F"],
["G", "H", "I"]];
The next table shows the effect of the in operator
on myArray02D:
Table 2. Further effects of the in operator| Logical expression |
Value of expression |
Value of sysVar.
ArrayIndex |
Comment |
| "DEF" in myArray01D |
true |
2 |
|
| "C" in myArray02D[1] |
true |
1 |
|
| "I" in myArray02D[3] from 2 |
true |
3 |
Search begins at the third row, second element |
| "G" in myArray02D[2] from 2 |
false |
0 |
Search ends at the last element of the row
being reviewed |
| "G" in myArray02D[2] from 4 |
false |
0 |
The second index is greater than the number
of columns available to search |