TStringList.IndexOfName

From Soldat Community Wiki
Jump to: navigation, search
function IndexOfName(Name: string): Integer
 Name: name to be searched
 Result: -1 if not found, index of found name otherwise

Description

IndexOfName searches in the list of strings for a name-value pair with name part Name. If such a pair is found, it returns the index of the pair in the stringlist. If no such pair is found, the function returns -1.
The search is done case-insensitive.

Example

var
  s: TStringList;

begin
  s := File.CreateStringList();
  s.Append('a=1');
  s.Append('b=2');
  s.Append('c=3');
  s.Append('d=4');
  s.Append('e=5');

  WriteLn(inttostr(s.IndexOfName('b')));
  // 1
  
  s.Free;
end.