Example: Conditional statements in expressions
- IMPORTANT:Keep the following in mind when using conditional statements:
- The condition portion of the statement can be any numeric or Boolean expression.
- If the condition is a numeric expression, including a tag, zero is treated as false and any non-zero value is treated as true.
- Using a string operand (string Literals, string properties, string tags, or the result of a String Operation) as the condition of a conditional statement is not supported.
- All parts of a conditional statement are required.
- The
Function | Description | Example: If tag1 = 5 and tag2 = 7, then: |
IIF, Iif, iif | Evaluates with the same rules as numeric operands. If the condition evaluates to 0 (false), the second value is used. If the condition evaluates to non-zero (true), the first value is used. Use this format: IIF(condition, value if true, value if false) | IIF( tag1 > tag2, tag1, tag2 ) returns 7 (the value of tag2) because tag1 is not greater than tag2 |
?: | The following requirements are specific to the ?: statement:
Use this format: condition ? value if true : value if false | (tag1 > tag2) ? tag1 : tag2 returns 7 (the value of tag2) because tag1 is not greater than tag2 |
Provide Feedback