If

Determines whether the contents of numExpression are logically true, then returns the value of numThen or optNumElse accordingly.

Function Group Execution Windows Embedded Thin Client
If Logical Synchronous Supported Supported Supported

Syntax

If( numExpression, numThen, optNumElse )
numExpression
Tag or expression used as the condition in the function.
numThen
Tag or expression used if the condition is logically true.
optNumElse
Optional tag or expression used if the condition is logically false.

Returned value

numThen If the numExpression is logically true.
optNumElse If the numExpression is logically false.
No value returned If the numExpression is logically false and there is no optNumElse in the function.

Notes

The numExpression parameter can be a combination of logic statements (AND, OR, and NOT). For example, If(TagA>TagB AND TagA=10,1,0).

The numThen parameter can be another function, including the If() function. Therefore, you can use If() functions in cascade. For example, if(TagA>TagB,If(TagA<TagC,1, 2),3).

Examples

Tag Name Expression
Tag If( 5 > 4,10, 6 ) // Returned value = 10
Tag If( 5 < 2, 0, 2 ) // Returned value = 0
Tag If( 3 = 9, 67 ) // No Returned value. (Tag retains previous value.)