IfThen

Description: Conditionally Execute Statements. This statement executes a statement if the condition parameter is true.
Returns: Nothing
Usage: Script only.
Function Groups: Logic Control
Related to: Ternary Operator (IfElse) | Cond | Execute | IfElse
Format: IfThen(Condition, Expression1, Expression2, ...)
Parameters:  
Condition   
Required. An expression that will indicate whether the Expression parameters are executed. If this is true, the Expression parameters will be executed.
Expression1, Expression2, ... default }
Required. Any statements to be executed when Condition is true. Any number of Expression parameters may be listed. They are executed once in the order that they are listed.
Comments: This statement may only appear in a script.

Example:

If 1 Main;
[
  IfThen(Valid(tankPtr) && fluidLevel > 1000, 
    startPump = 1, 
    activeTankNum++, 
    msg = "Changing tanks...");  
]

The statement in the script will test to see if tankPtr exists (is valid) and if fluidLevel > 1000, if these conditions are both true, the series of actions will be taken. VTScada does not use short-circuit evaluation. Both parts of the condition will always be checked (and evaluated if required).