EGL Reference Guide for iSeries


in

The operator in is a binary operator used in an elementary logical expression that has the following format:



Syntax diagram for the operator in

searchValue
A literal or item, but not a system variable.

array
A one-dimensional or multidimensional array. The operator in operates on a one-dimensional array, which may be part of a multidimensional array.

subscript
An integer, or an item (or system variable) that resolves to an integer. The value of a subscript is an index that refers to a specific element in an array.

An item used as a subscript of an array can not itself be an array element. In each of the following examples, myItemB[1] is both a subscript and an array element; as a result, the following syntax is not valid:

  /* the next syntax is not valid */ 
  myItemA[myItemB[1]]
 
  // this next syntax is not valid; but only 
  // because myItemB is myItemB[1], the 
  // first element of a one-dimensional array
  myItemA[myItemB]

dataTableItem
The name of a dataTable item. The item represents a column in the data table. The in operator interacts with that column as if the column were a one-dimensional array.

The logical expression resolves to true if the generated program finds the search value. The search begins at the element identified by the last array subscript. If array is a one-dimensional array, the last subscript is optional and defaults to 1. If array is a multidimensional array, the following statements are true:

In relation to both one-dimensional and multidimensional arrays, the search ends at the last element of the one-dimensional array under review.

The logical expression that includes in resolves to false in either of these cases:

If the elementary logical expression resolves to true, the operation in sets the system variable sysVar.arrayIndex to the subscript value of the element that contains the search value. If the expression resolves to false, the operation sets sysVar.arrayIndex to zero.


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