Difference between revisions of "TStringList.IndexOf"

From Soldat Community Wiki
Jump to: navigation, search
m
m
Line 4: Line 4:
  
 
==Description==
 
==Description==
The function returns the position of ''S'' if it is found in the list, or ''-1'' if the string is not found in the list.
+
The function returns the position of ''S'' if it is found in the list, or ''-1'' if the string is not found in the list. Search is case-insensitive
  
 
==Example==
 
==Example==

Revision as of 11:44, 17 March 2019

function IndexOf(const S: String): Integer
 S: string to be found
 Result: index of S in a TStringList if it has been found, -1 otherwise

Description

The function returns the position of S if it is found in the list, or -1 if the string is not found in the list. Search is case-insensitive

Example

var
  s: TStringList;
  i: integer;

begin
  s := File.CreateStringList();
  s.Append('a'); // index 0
  s.Append('b'); // index 1
  s.Append('d'); // index 2

  i := s.IndexOf('b'); 
  // i = 1

  i := s.IndexOf('c'); 
  // i = -1

  s.Free;
end.