Difference between revisions of "TStringList.IndexOfName"
m (→Example) |
m (→Example) |
||
Line 20: | Line 20: | ||
s.Append('e=5'); | s.Append('e=5'); | ||
− | + | WriteLn(inttostr(s.IndexOfName('b'))); | |
− | |||
− | |||
− | |||
− | WriteLn(inttostr(s.IndexOfName( | ||
// 1 | // 1 | ||
Latest revision as of 13:38, 24 August 2013
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.