Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Edge HMI

If

  • Last UpdatedOct 29, 2026
  • 2 minute read

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

Function

Group

Execution

String Exp.

Windows

Windows Embedded

IoT View

Thin Clients

Mobile Access

If

Logical

Synchronous

Yes

Supported

Supported

Supported

Supported

Supported

Syntax

If(numExpression,numThen,optNumElse)

If ( numExpression , numThen { | ,optNumElse } )

numExpression

The tag or expression to be evaluated.

numThen

The tag, expression, or value that is returned if numExpression is logically true (that is, not 0).

optNumElse

The tag, expression, or value that is returned if numExpression is logically false (that is, 0).

This parameter is optional; see "Returned value" below.

Return value

This function returns either numThen or optNumElse, depending on how numExpression is evaluated.

If numExpression is logically false and optNumElse is not specified, this function returns no value. Furthermore, if a project tag is configured to receive the value returned by this function but the function returns no value, the project tag retains its existing value.

Notes

numExpression can be a combination of logic statements (for example, AND, OR, NOT). For example:

If(TagA>TagB AND TagA=10,1,0)

Both numThen and optNumElse can be functions as well, resulting in direct actions. For example:

If(TagA>TagB,Open("Screen2"),0)

You can even create nested If functions for more complex logic. For example:

If(TagA>TagB,If(TagA<TagC,Open("Screen2"),Open("Screen3")),0)

Nested If functions are supported only in Built-in Language interfaces, however; they are not supported in VBScript interfaces. For more information, see About the Built-in Language interface.

In VBScript interfaces, each parameter is validated when the function is executed, so if one of the parameters is another If function, that function might be executed regardless of whether it should be. Use VBScript's own If…Then…Else statement instead.

If you are using Mobile Access to view your project, nested If functions are not supported at all. This is due to how functions are converted to JavaScript for execution on Mobile Access.

Examples

Evaluate the expression "5 > 4", and then return the corresponding value (that is, return 10, because the expression is logically true):

If(5>4,10,6)

Evaluate the expression "5 < 2", and then return the corresponding value (that is, return 2, because the expression is logically false):

If(5<2,0,2)

Evaluate the expression "3 = 9", and then return the corresponding value (that is, return no value, because the expression is logically false and optNumElse is not specified):

If(3=9,67)

In This Topic
Related Links