Event Specifiers (Watch*)

In nnCron, one can cause a task to start at a specific event.

When you are creating a task, you can "tell" nnCron what events it is supposed to watch for; when this event happens, nnCron will start the task. You can use event specifiers together with time specifiers and conditions (rules), i. e. time and rules would be also checked before executing a task. (See also description of option Also). Specifiers are placed in the beginning of a task, before the Action: section.


#( test_watch
\ task will be started if all of these conditions are true:
\ file named  'test.sem' has been created or changed,
\ the current time is between  12:00 and 15:00 inclusive,
\ and you are online (i.e. there exists an active remote connection)
Time: * 12-15 * * * *
WatchFile: "c:\test.sem"
    \ ... performing some useful actions

A task can contain two or more event specifiers which are connected with logical OR, i. e. the action would be performed if at least one of the specified events takes place.


#( test_multiple_watch
\ task will be started if a file named  'test.sem' is been created or changed,
\ or if a window of Internet  Internet  Explorer is opened
\ or if the current time is between  18:00 and 20:00 inclusive
Time: * 18-20
WatchFile: "c:\1.sem"
WatchWinCreate: "*Internet Explorer"
    \ ... performing some useful actions

Events of the same type cannot happen more frequently than it is specified in the parameter MonitorResponseTime: in nncron.ini. This parameter sets the minimum length of time (in milliseconds) between two consecutive events. By default, its value is 100 milliseconds, i.e. 1/10th of a second. If necessary, one can set a separate response time for each task. To do this, change the VALUE-variable MonitorResponseTime before a Watch* word you want to modify:

<time_in_ms> TO MonitorResponseTime

Redefining would also affect all the tasks located in crontab after this one, so it is advisable to restore the default value immediately after the Watch* word.


#( watch_task
MonitorResponseTime        \ saving the value in the stack
1000 TO MonitorResponseTime \ setting new value (1000 ms)
WatchDir: "c:\xxx\yyy"
TO MonitorResponseTime     \ restoring the old value
    MSG: "c:\xxx\yyy has been changed"

You can find the list of task options in nnCron Key Words - Monitoring the Events (Watch*)