Sfairadora

  • Reference Guide

wait_for_change

wait_for_change(var)
wait_for_change(var, new_value)
wait_for_change(var) time
wait_for_change(var, new_value) time
The function waits for a change of the variable or data item var. The execution is resumed only after the value of specified variable changes. If the parameter new_value is specified, its value is stored to the variable var after its value changes. The value change and setting the new_value is an atomic operation. Therefore, if the new_value is identical to the original value of the variable, and more than one function waits for the change of the variable, only one of the functions will be released.
If the parameter time of the type Time (note it is typed after the closing parentheses), the function will wait at most that time interval (the time value is a time-out). If the time-out elapses before the variable changes, the function returns an error.
The function can be executed only asynchronously. An attempt of synchronous execution returns an error.

Return Value

The return value is the value of the variable var after its value was changed. If the new_value parameter is specified, the value before setting the new_value is returned.