Skip to main content
Version: 8.1

if

This function is used by Ignition's Expression language.

Description​

This function evaluates the expression condition, and returns the value of trueReturn or falseReturn depending on the boolean value of condition.

Syntax​

if(condition, trueReturn, falseReturn)

  • Parameters

    • Object condition - The condition to evaluate.

    • Object trueReturn - The true return value.

    • Object falseReturn - The false return value.

  • Results

    • Object - Returns the trueReturn if the condition is true, falseReturn if it is False.

Examples​

Code Snippet
 if(1, "Yes", "No") //would return "Yes"
Code Snippet
 if(0, "Yes", "No") //would return "No"
Code Snippet
 if({Root Container.CheckBox.selected}, "Selected", "Not Selected") //Would return with a description of the state of the checkbox.
Code Snippet
//Nests if functions to check the value of 2 different Tags, and return a message based on which ones are greater than 0.
if({tag1} > 0, if({tag2} > 0, "Both Tags are positive.", "Tag 1 is positive."), if({tag2} > 0, "Tag 2 is positive.", "Neither Tag is positive."))