MyChat Scripts Engine: mDeleteAutoScriptByName
Deleting all time-script entries which were added for automatic execution.
Syntax
function mDeleteAutoScriptByName(sScriptName: string): integer;
Parameters and return values
Parameter |
Type |
Value |
sScriptName |
string |
time-script name. |
Function result
Returns the number of specified scripts which were deleted from the execution queue.
Example
In this example, we added three same scripts with the name "testautoscript". They are taken from the template script. The script is called "TemplateScript" from the "Custom" section. The execution time is set as already past (-1, -2, -3 minutes from the current time). This "trick" means that in the next second all three scripts will be executed immediately by the scheduler.
Right after this operation, the function mDeleteAutoScriptByName is called to delete the scripts from the execution queue. The debugging console shows, how many scripts were deleted.
As a result, all scheduled scripts are immediately deleted without execution.
var
n: integer;
begin
mAddAutoScriptFromTemplate('testautoscript', 'Custom\TemplateScript', IncMinute(Now, -1));
mAddAutoScriptFromTemplate('testautoscript', 'Custom\TemplateScript', IncMinute(Now, -2));
mAddAutoScriptFromTemplate('testautoscript', 'Custom\TemplateScript', IncMinute(Now, -3));
n := mDeleteAutoScriptByName('testautoscript');
mLogScript('Time scripts removed: ' + inttostr(n), '');
end.
Script work result
[18:39:14] (Log "mDeleteAutoScriptByName"): Time scripts removed: 3
[18:39:14] (Run "mDeleteAutoScriptByName"): Script operation time: 4 ms
[18:39:14] (Run "mDeleteAutoScriptByName"): Script done successfully.