If

The function If evaluates a specified tag/expression to determine whether it is logically true or false, and then it returns a corresponding value.

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

Syntax

  If(numExpression,numThen,optNumElse)  
Web Studio Help topics2ffunctions logical if.xml d413244e110 If
numExpression
The tag or expression to be evaluated.
numThen
The tag, expression, or value that is returned if numExpression is logically true (i.e., not 0).
optNumElse
The tag, expression, or value that is returned if numExpression is logically false (i.e., 0).

This parameter is optional; see “Returned value” below.

Returned value

This function returns either numThen or optNumElse, depending on how numExpression is evaluated. However, if numExpression is logically false and optNumElse is not specified, this function returns no value.

Notes

numExpression can be a combination of logic statements (e.g., AND, OR, NOT). For example:
  If(TagA>TagB AND TagA=10,1,0)  
numThen can be another function, including the function If. Therefore, you can use the functions in cascade. For example:
  If(TagA>TagB,If(TagA<TagC,1,2),3)  

Examples

Evaluate the expression “5 > 4″, and then return the corresponding value (i.e., return 10, because the expression is logically true):
  If(5>4,10,6)  
Evaluate the expression “5 < 2″, and then return the corresponding value (i.e., return 2, because the expression is logically false):
  If(5<2,0,2)  
Evaluate the expression “3 = 9″, and then return the corresponding value (i.e., return no value, because the expression is logically false and optNumElse is not specified):
  If(3=9,67)  

If