MyChat Scripts: function TStringList.Delete, delete a string from the list by its number
Delete a string by its index. An indexation starts with zero. Get a number of strings by using the property Count.
Syntax
procedure TStringList.Delete(x: integer);
Parameters and return values
Parameter |
Type |
Value |
x |
integer |
index of a string you need to delete. |
Example
var
SL: TStringList;
i: integer;
begin
SL := TStringList.Create;
for i := 1 to 10 do
SL.Append(IntToStr(Random(100) + 50));
mLogScript(SL.CommaText, 'Before');
for i := SL.Count - 1 downto 0 do
if length(SL[i]) > 2 then SL.Delete(i);
mLogScript(SL.CommaText, 'After');
SL.Free;
end.
Script work result
[17:23:47] (Log "DeleteMethod"): [Before] 87,117,115,118,140,67,106,61,71,124
[17:23:47] (Log "DeleteMethod"): [After] 87,67,61,71
[17:23:47] (Run "DeleteMethod"): Script operation time: 5 ms
[17:23:47] (Run "DeleteMethod"): Script done successfully.