WAITFOR Command

Purpose

Waits for a process condition to occur. The Program block checks for this condition once per scan period. If the condition occurs or you have a previous MAXWAIT command that times out, the Program block continues with the next command.

Syntax

WAITFOR expression

Parameter

expression – compares values in the IF command. The syntax of an expression for these commands is:

operand1 relationaloperator operand2

For more information on these arguments, refer to the topic Using Command Arguments.

Example

To wait for the current value of the block, AGITSPEED, to equal 400, enter:

WAITFOR AGITSPEED = 400

TIP: In rare instances, you can have a Program block that waits for a specific value from a block to test a condition, but because of the unavoidable round-off errors that occur in digital systems, the block consistently sends out a slightly different value that never satisfies the condition. For example, 10 might not equal 10, since the block might really be comparing 10.0001 to 10.0003. The easiest way around this problem is to add a SETLIM command to create a limit of precision on the value that is received. The SETLIM statement lets you assign an inclusion limit for the comparison, such as +/- 0.1. If you do use the SETLIM command before your WAITFOR command, remember that you must account for the precision limit that you set for the condition.