arrayIndex
The sysVar.arrayIndex system variable contains the results of the search of an array:
- The number of the first element in an array that matches the search condition of a simple logical expression with an in operator, as shown in a later example.
- The number of the last element modified in the target array after a move...for count statement.
- Zero, if no array element matches the search condition.
Characteristics
sysVar.arrayIndex has the following characteristics:
- Primitive type
- INT
- Data length
- 9
- Value saved across segmented converse?
- No
Example
Assume that the record variable
myRecord is based
on the following definition: Record AddrSerialRect type SerialRecord {
fileName = "myFile" }
10 zipCodeArray CHAR(9)[100];
10 cityStateArray CHAR(30)[100];
endFurthermore, 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.
Compatibility considerations
| Platform | Issue |
|---|---|
| JavaScript™ generation | The function sysVar.arrayIndex is not supported |