MyChat Scripts: fucntion TStringList.Add, add a string to the list and get its index
"For developers", "Server scripts", "Functions description", "Strings", "TStringList", "Methods", "Add".
Adding a string to the list and getting its index.
Syntax
function TStringList.Add(s: string): integer;
Parameters and return values
Parameter |
Type |
Value |
s |
string |
a string for adding to the list. |
Function result
A string index. It is not necessary a sequence number as the list can be sorted. A numeration starts with zero.
Example
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.
Script work result
[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.