Array.LastIndexOf

Syntax

LastIndexOf(Value: Variant): Integer;

Parameters

Value. The value that should be found in the array.

Description

The LastIndexOf method searches for the specified value in the array and returns the index of the last occurrence of the corresponding element.

Comments

This method is supported for one-dimensional arrays only.

If the value is not found, the method returns -1.

Example

Add a link to the MathFin system assembly.

Sub UserProc;
Var
    Ar: Array[0..20Of Integer;
    i, j: Integer;
Begin
    For i := 0 To 20 Do
        Ar[i] := Math.RandBetweenI(050);
    End For;
    j := Ar.LastIndexOf(10);
End Sub UserProc;

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

See also:

Array