"For developers", "Server scripts", "Functions description", "Strings", "TStringList", "Methods", "Add".
Adding a string to the list and getting its index.
function TStringList.Add(s: string): integer;
Parameter |
Type |
Value |
---|---|---|
s |
string |
a string for adding to the list. |
A string index. It is not necessary a sequence number as the list can be sorted. A numeration starts with zero.
var
SL: TStringList;
begin
SL := TStringList.Create;
SL.Sorted := true;
mLogScript(IntToStr(SL.Add('One')), '');
mLogScript(IntToStr(SL.Add('Two')), '');
mLogScript(IntToStr(SL.Add('Three')), '');
mLogScript(SL.Text, '');
SL.Free;
end.
[22:45:12] (Log "AddMethod"): 0
[22:45:12] (Log "AddMethod"): 1
[22:45:12] (Log "AddMethod"): 1
[22:45:12] (Log "AddMethod"): One
Three
Two
[22:45:12] (Run "AddMethod"): Script operation time: 5 ms
[22:45:12] (Run "AddMethod"): Script done successfully.