Object «script»
This article is automatically translated from Russian by Google Translator.
Represents methods of controlling script execution and accessing operating system functions.
Method | Description |
Sets the end-of-run flag for an event-driven program. | |
Returns a random number from the specified range. | |
Считывает всё содержимое указанного файла в массив строк. | |
Deletes the specified file. | |
Sets the event-oriented program flag. | |
Выполняет переданную в качестве параметра команду консоли операционной системы. | |
Returns the time stamp - the number of milliseconds elapsed since the beginning of January 1, 1970 GMT. | |
Creates and returns a timer. | |
Suspends script execution for the number of milliseconds passed. | |
Writes a string to a file. |
Sets the end-of-run flag for an event-driven program. As soon as the current event handler completes, the script execution will end.
JavaScript
Python
script.quit();
script.quit();
Returns a random number from the specified range.
JavaScript
Python
script.random(min, max);
script.random(min, max);
The range boundaries must be specified as parameters.
JavaScript
Python
var a = script.random(0, 10); // random number from 0 to 10
a = script.random(0, 10); # random number from 0 to 10
Reads the entire contents of the specified file into a string array.
JavaScript
Python
script.readAll('fileName');
script.readAll('fileName');
As a parameter, you must specify the name of the file with the extension.
JavaScript
Python
var lines = script.readAll('input.txt'); // reads the text file input.txt
lines = script.readAll('input.txt'); # reads the text file input.txt
Deletes the specified file.
JavaScript
Python
script.removeFile('fileName');
script.removeFile('fileName');
As a parameter, you must specify the name of the file with the extension.
JavaScript
Python
script.removeFile('file.txt'); // delete file file.txt
script.removeFile('file.txt'); # delete file file.txt
Sets the event-oriented program flag. When the script finishes, it is not unloaded from memory but continues to wait for events to occur until one of the handlers calls the "quit" method.
JavaScript
Python
script.run();
script.run();
Executes the command transmitted.
JavaScript
Python
script.system();
ript.system();
As a parameter, you must specify the operating system console command.
JavaScript
Python
script.system("reboot");
script.system("reboot");
Returns the time stamp - the number of milliseconds elapsed since the beginning of January 1, 1970 GMT.
JavaScript
Python
script.time();
script.time();
Creates and returns a timer (class
QTimer
) that sends a timeout
signal every n milliseconds.JavaScript
Python
script.timer(n);
script.timer(n);
n
is passed as a parameter.JavaScript
Python
script.timer(1000);
script.timer(1000);
Suspends script execution for the number of milliseconds passed.
JavaScript
Python
script.wait(msCount);
script.wait(msCount);
The number of milliseconds is passed as a parameter.
JavaScript
Python
script.wait(1000); // stop the execution of the script for one second
script.wait(1000); # stop the execution of the script for one second
Writes a string to a file.
JavaScript
Python
script.writeToFile('fileName', 'text');
script.writeToFile('fileName', 'text');
The file name and the line to be written should be specified as parameters.
JavaScript
Python
script.writeToFile('output.txt', 'Hello, world'); // write "Hello, world" in the output.txt file
script.writeToFile('output.txt', 'Hello, world'); # write "Hello, world" in the output.txt file
Last modified 2yr ago