function IndexOfItem(const S: string; const Direction: TDirection): Integer; overload;
IndexOf from either end: FromBeginning the first item equal to S, FromEnd the last; -1 when there is none.
| # | Name | Description |
|---|---|---|
| 1 | S | The text, every text kind. |
| 2 | Direction | FromBeginning: the first equal item; FromEnd: the last. |
Returns: Integer - The item's index, or -1.
Examples
The last match.
uses Substr, System.Types;
procedure Example;
var List: TSubstringList;
begin
List := TSubstringList.Create(4);
try
List.Add('x');
List.Add('y');
List.Add('x');
Assert(List.IndexOfItem('x', FromBeginning) = 0);
Assert(List.IndexOfItem('x', FromEnd) = 2);
finally
List.Free;
end;
end;
See Also: TSubstringList.IndexOf