IndexOfPos(Value: String; StartIndex: Integer): Integer;
Value. Element value that should be found.
StartIndex. Index of the element, from which search is executed.
The IndexOfPos method is used to directly search value.
The search is executed starting from the element with the StartIndex index. If the search is successful, it returns element index; otherwise it returns -1.
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.IndexOfPos("Number 25",Double.FloorInt(StrL.Count/2));
End Sub Main;
After executing the example a dynamic array of strings is generated, and direct search of the element with the Number 25 value is executed in the second part of the array. The "i" variable contains the number of the first found element in case of successful search.
See also: