WAITs and Variables
TurnipTruck
Posts: 1,485
There is something about WAITs I have always been uncertain about. If the event put into a WAIT contains a variable, at the time of execution will the event reflect the variable's value at the time the wait was started, or when it event is executed?
Example
Will the master message say that the variable =1 or 0?
Are there variations to this rule? I beleive that I have run into situation where it has gone either way.
How about when the variable has to do with a reference to a device in a DEV array? If the variable changes from the start of the wait until its execution, what value will be used in the execution of the event?
Thank you.
Example
_EVENT: { nVARIABLE=0 WAIT 10 SEND_STRING 0,"'The Variable=',ITOA(nVARIABLE)" nVARIABLE=1 }
Will the master message say that the variable =1 or 0?
Are there variations to this rule? I beleive that I have run into situation where it has gone either way.
How about when the variable has to do with a reference to a device in a DEV array? If the variable changes from the start of the wait until its execution, what value will be used in the execution of the event?
_EVENT: { nVARIABLE=0 WAIT 10 SEND_STRING dDEV[nVARIABLE],'blah blah' nVARIABLE=1 }
Thank you.
0
Comments
In your examples, the value of the variable would be the value at the time the WAIT is executed and not the value of the variable at the time the WAIT was queued. Your first SEND_STRING example should indicate the value is 1 and the second SEND_STRING example should send the string to dDev[1].
One interesting case that would be worth testing relates to arguments to functions and calls. The manual indicates copies of these values are made at the time the WAIT is queued so there may be cases where a variable is modified after a WAIT has been queued but before it executes and the modified value is not reflected in the execution of the WAIT.
Reese