Field-Map Scripting

4.5.1.26 IndexOfName

IndexOfName property


Prototype:

property IndexOfName(const Name :string) :integer;

Description:

IndexOfName property returns index position of the first name-value pair string which matching with a string parameter. If string (name-value) does not exist in the StringList then returns -1.

Syntax:

variable := StringList.IndexOfName (Name);


Part

Description


variable

A variable declared as an integer


StringList

A reference to an instance of a TStringListWrapper

Return value:

an index position of the first name-value pair string which matching with a string parameter. Or -1 if the string does not exist




Example:


var

 strList1 : TStringListWrapper;

 t, s : string;

 i : integer;


begin

 strList1 := CreateStringList;


 strList1.BeginUpdate;

 strList1.Add('Picea=1');

 strList1.Add('Fagus=2');

 strList1.Add('Pinus=3');

 strList1.Add('Larix=4');

 strList1.Add('Abies=5');

 strList1.EndUpdate;


 i:= strList1.IndexOfName('Pinus');


 t:= strList1.Text;


 ShowMsg('Index of name is ' + IntToStr(i));


 strList1.Free;

end.



Output in Field-Map Data Collector:



See also:

Free; Duplicates; Sorted; CaseSensitive; BeginUpdate; EndUpdate; Add; AddStrings; Assign; Clear; Delete; Count; Exchange; Move; Find; IndexOf; Insert; Sort; LoadFromFile; SaveToFile; Strings; Text; Delimiter; DelimitedText; NameValueSeparator; IndexOfName; Name; Value; AsVarArray