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 |
If( numExpression, numThen, optNumElse )
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. |
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).
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.) |