Array.IndexOf

Syntax

IndexOf(Value: Variant): Integer;

Parameters

Value - value that should be found in the array.

Description

The IndexOf method searches for the value passed as the Value input parameter in the array and returns the index of the first occurrence of the corresponding element. If the value is not found, the method returns "-1".

NOTE. This method is supported for one-dimensional arrays only.

Example

Sub Main;

Var

Ar: Array[0..20] Of Integer;

i, j: Integer;

Begin

For i := 0 To 20 Do

Ar[i] := Math.RandBetweenI(0, 50);

End For;

j := Ar.IndexOf(10);

End Sub Main;

After executing the example random data is written to the Ar one-dimensional array, the "j" variable will contain the index of the first value 10 found in the array.

See also:

Array