IStringList.IndexOfRange

Syntax

IndexOfRange(Value: String; StartIndex: Integer; Count: Integer): Integer;

Parameters

Value. Element value that should be found.

StartIndex. Element index, starting from which the search is performed.

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

Description

The IndexOfRange method directly searches for the element in array range.

Comments

The method returns index of element in case of successful search, otherwise it returns -1. The range starts from the element with the StartIndex index and contains Count of elements.

Example

Sub Main;

Var

StrL: IStringList;

i: Integer;

Begin

StrL:=New StringList.Create;

For i:=0 To Math.RandBetweenI(50,100) Do

StrL.Add("Number "+Math.RandBetweenI(0,100).ToString);

End For;

i:=StrL.IndexOfRange("Number 25",10,StrL.Count-20);

End Sub Main;

After executing the example a dynamic array of strings is generated, and direct search of the 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