IStringList.LastIndexOfRange

Syntax

LastIndexOfRange(Value: Srting; StartIndex: String; Count: Integer): Integer;

Parameters

Value. Element value that should be found.

StartIndex. Index of the element, from which search is executed.

Count. Number of elements in the range, in which the search is executed.

Description

The LastIndexOfRange method reversely searches for the element in the specified range.

Comments

The method returns element index in case of successful search, and -1 if the value is not found.

Example

Sub UserProc;
Var
    StrL: IStringList;
    i: Integer;
Begin
    StrL := New StringList.Create;
    For i := 0 To Math.RandBetweenI(50100Do
        StrL.Add("Number " + Math.RandBetweenI(0100).ToString);
    End For;
    i := StrL.LastIndexOfRange("Number 25"10, StrL.Count - 20);
End Sub UserProc;

After executing the example a dynamic array of strings is generated, and reverse search of the Number 25 value is executed in the whole array, except for the first and last 10 elements. In case of successful search, the "i" variable contains index of the found element.

See also:

IStringList