WAIT (Statement)


Stops program processing based on a condition.


WAIT <Conditional expression> [,<Timeout time> [,<Storage variable>]]


This statement stops program processing until <Conditional expression> is satisfied.
If <Timeout time> is set, control stops the execution of a WAIT statement after the designated time elapses and proceeds to the next command. Infinite stoppage can be avoided by using this.
<Timeout time> is expressed in ms.
The reevaluation interval for monitoring <Conditional expression> or <Timeout time> depends on the priority of the task.
In Version 1.8 or later, when <Storage variable> is set, the WAIT command will assign TRUE (1) or FALSE (0) to the designated variable if control passes out of the WAIT statement by the satisfied <Conditional expression> or by timeout, respectively.



When using timeout time, if an instantaneous stop during execution of an instruction is executed and the system is restarted, the designated time will elapse even during suspension.


DEFINT li1, li2, li3, li4, li5
WAIT li1 = 1
'Waits until li1 = 1 is satisfied.
WAIT li2 = 0, 2000
'Waits until li2 = 0 is satisfied.
'Even if it is not satisfied
'after 2 seconds, the system
'proceeds to the next statement.
WAIT li3 = li4, li5
'Waits until li3 = li4 is satisfied.
'Even if it is not
'satisfied after the time of li5,
'the system proceeds to the next statement.
WAIT IO[10] = ON
'Waits until the 10th IO comes ON.

[Version 1.8 or later]
WAIT li3 = li4, li5, li6
'Wait until li3 = li4. If the conditional expression
'is not satisfied within li5 period, pass control to
'the next statement and assign FALSE to li6.
'If satisfied within li5 period, pass control to the
'next statement and assign TRUE to li6.


Top