Conditions for Starting a Task (Rules)
It is possible to "tell" nnCron to check whether a certain condition exists before it starts to perform the actions listed in the task. Actions defined in Action: section will be executed only if this condition is found to be true. In order to check whether or not a condition is true, use word Rule:. In should be placed in the beginning of a task, before Action:.
Rule: <any sequence of Forth words returning a flag>
To reverse a rule, add after it "0=" (according to the rules of postfix notation, this means "equals to 0", i.e. FALSE) or "NOT:".
Rule: <any sequence of Forth words returning a flag> 0=
It is possible to use more than one Rule: construct in the same task. In this case, Rule: constructs are combined with logical "OR", in other words, the action will be performed if at least one of the conditions returns TRUE.
#( test_rule \ the actions will be executed if either one of the first 2 checks \ returns 'TRUE' or if "check3" returns 'FALSE'
Rule: <check1>
Rule: <check2>
Rule: <check3> 0= Action: \ ... performing some useful actions )#
A much more convenient way to achieve the same result is to combine several conditions within the same Rule: construct. In this case, words AND and OR are used as logical operators. Syntax of combined conditions follows the rules of postfix notation that is used in Forth language (<condition 1> <condition 2> <logical operator>):
\ Returns TRUE only if both conditions are true Rule: <check1> <check2> AND \ Returns TRUE if either or both of conditions are true Rule: <check1> <check2> OR
Quite often it becomes necessary to use more complex combinations of conditions within a Rule: construct. The following example illustrates how these statements look in Forth language:
\ expression '(a OR b) AND c' : a b OR c AND \ expression 'a AND b AND c AND NOT d' : a b AND c AND d NOT AND \ expression '(a AND b AND c) OR (d AND (e OR f))' : a b AND ñ AND d e f OR AND OR
Below is a list of some of predefined conditions which are convenient to use with word Rule: or in Action: section of a task (you can find all other conditions in "nnCron Key Words"):