<< Prev        Next >>

ID : 218

Wait

Function

To have a task wait for the conditional expression to be True.

Syntax

Wait conditional expression[, timeout period[, storage variable]]

Guaranteed Entry

Conditional expression
Designate a Conditional Expression.
Timeout period
Specify the timeout period by double precision real number type data. The unit is "ms." This is an optional value. If this is omitted, the next line is not executed until the conditional expression becomes "True."
Storage variable
Specify a variable to record whether the Wait line is escaped by establishment of the conditional expression or timeout. "1" or "0" of Integer Type data is assigned to the specified variable.

Description

Task execution is suspended until the designated conditional expression goes "True."
Wait command checks the change of condition every 1 ms.
If it is escaped by establishment of conditional expression, "1" is assigned to storage variable and if by timeout, "0" is assigned.

Attention

  • Timeout period elapses even during pausing or step stop.
  • There may be an error in specified timeout period due to task loading, etc. Moreover, an error occurs if the specified time is very short.
  • Wait command, which normally includes a rest-time of 1ms, keeps running until the conditional expression is established. Therefore, if two or more tasks run Wait command simultaneously, the process of the controller may be overloaded. Adjust the timing of the rest-time by using #Pragma Optimize ("wait-idling-time") command so as to reduce the load on the controller.

Example

'!TITLE "Conditional Program Stop"
' Stop the program until the conditional expression is satisfied
Sub Sample_Wait

  ' Wait until No. 128 of IO is turned ON, and if the condition is not satisfied in 3 seconds, 
transfer to the next processing Wait IO[128] = ON, 3000 ' Display the 128th value of IO on the message output window PrintDbg IO[128] End Sub

ID : 218

<< Prev        Next >>