run()
run() → boolean
Returns true while the script should keep running; the required condition for every main loop.
Polls the script scheduler. While the script should keep executing, run()
returns true; when the device needs the script to stop (for example during a
configuration update), it returns false.
Binding your main loop to run() allows the device to stop the script during
configuration updates and prevents unexpected behavior. Your script must exit
within 5 seconds of run() returning false, otherwise it will not be
updated during configuration changes, a device restart will be required, and
objects referenced by the script may become undefined.
Calling run() also syncs the IO variables with your local variables — see
syncIO() for mid-loop synchronisation.
Returns
boolean
true while the script should continue; false when it must shut down.
Example
while(run()){
// monitoring logic here
waitMS(100);
}
// falls through here during a configuration update — exit promptly