arrayIndex

The system variable SysVar.arrayIndex contains a number:

You can use SysVar.arrayIndex as any of these:

The characteristics of SysVar.arrayIndex are as follows:
Primitive type
BIN
Data length
4
Is value always restored after a converse?
Only in a non-segmented text program; for details see Segmentation

Example

Assume that the record myRecord is based on the following part:
  Record mySerialRecPart
    serialRecord:
      fileName = "myFile"
    end
    10 zipCodeArray   CHAR(9)[100];
    10 cityStateArray CHAR(30)[100];
  end

Furthermore, assume that the arrays are initialized with zip codes and city-and-state combinations.

The following code sets the variable currentCityState to the city and state that corresponds to the specified zip code:

  currentZipCode = "27540";
  if (currentZipCode in myRecord.zipCodeArray)
    currentCityState = myRecord.cityStateArray[SysVar.arrayIndex]; 
  end

After the if statement, SysVar.arrayIndex contains the index of the first zipCodeArray element that contains the value of "27540". If "27540" is not found in zipCodeArray, the value of SysVar.arrayIndex is 0.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.