--- title: "if" description: "This function evaluates the expression condition, and returns the value of trueReturn or falseReturn depending on the boolean value of condition." --- # if > This function evaluates the expression condition, and returns the value of trueReturn or falseReturn depending on the boolean value of condition. **This function is used by Ignition's Expression language.** ## Description ## Syntax `if(condition, trueReturn, falseReturn)` ### Parameters | Type | Parameter | Description | |---------|--------------|-----------------------------------------------------------------------------| | Boolean | `condition` | A boolean expression that determines which return value is used. | | Object | `trueReturn` | The value returned if the condition evaluates to true. | | Object | `falseReturn`| The value returned if the condition evaluates to false. | ### Returns **Object** - Returns the trueReturn value if the condition is true, or the falseReturn value if the condition is false. ## Examples ```python title="Code Snippet" if(1, "Yes", "No") //would return "Yes" ``` ```python title="Code Snippet" if(0, "Yes", "No") //would return "No" ``` ```python title="Code Snippet" if({Root Container.CheckBox.selected}, "Selected", "Not Selected") //Would return with a description of the state of the checkbox. ``` ```python title="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.")) ```