[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The `if_equal' and `if_not_equal' conditions are used to hold a task until the value of a task is equal or different from a specified value.
A task which is holded by a `if_equal' condition, will wait until the value of the variable is equal to the specified value.
A task which is holded by a `if_not_equal' condition, will wait until the value of the variable is not equal to the specified value.
To show this, we'll create two tasks. The first will wait while the value of the variable `hold_t1' is equal to the value `YES'. The second will wait until the variable `start_t2' is different from `NO'.
Start the daemons if there're not running. We create two variable `hold_t1' and `start_t2'. We must create these variables twice : in `dio87d' and `dio87d' :
$ dio87c va hold_t1 $ dio87c va hold_t1 YES $ dio87c va start_t2 $ dio87c va start_t2 NO $ |
We initialize the value of `hold_t1' to `YES' and the value of `start_t2' to `NO'. These initialization are not made in `dio87d' because the value of these variables are not used in this daemon.
Then, we create the tasks `t1' and `t2' in the referential `r1'. We add an `add always' operation to these tasks to select it automatically when new days are created.
$ dio87c ra r1 $ dio87c rta r1 t1 $ dio87c rtoa r1 t1 add always $ dio87c rta r1 t2 $ dio87c rtoa r1 t2 add always $ |
We create the `if_equal' and `if_not_equal' conditions :
$ dio87c rtca r1 t1 if_equal hold_t1 NO $ dio87c rtca r1 t2 if_not_equal start_t2 NO $ |
The first condition means : wait until the value of the variable `hold_t1' is equal to `NO'. The second condition means : waint until the value of the variable `start_t2' is different from `NO'.
To verify this, we create a day `d1' from our referential :
$ dio87c rp r1 "2004-11-04" d1 $ |
The two tasks are waiting for conditions (`wait_for_condition') and the condition are waiting :
$ dio87c -- xtl -s d1 t1 wait_for_condition t2 wait_for_condition $ $ dio87c -- xtcl -s d1 t1 if_equal hold_t1 NO waiting $ $ dio87c -- xtcl -s d1 t2 if_not_equal start_t2 NO waiting $ |
We change the value of the variable `hold_t1' to `NO'
(vsv
command). The condition `if_equal hold_t1 NO'
is validated (`finished') and the task starts :
$ dio87c -- xtcl -s d1 t1 if_equal hold_t1 NO finished $ $ dio87c -- xtl -s d1 t1 terminated t2 wait_for_condition $ |
The task `t2' is always waiting for condition. We set the value of `start_t2' to `YES' to start this task :
$ dio87c vsv start_t2 OUI $ $ dio87c -- xtcl -s d1 t2 if_not_equal start_t2 NON finished $ $ dio87c -- xtl -s d1 t1 terminated t2 terminated $ |
It's possible to validate a `if_equal' or `if_not_equal' condition by using the `xtcv' command. This is useful to validate a condition without changing the value of a variable.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |