Linx Main Linx Help

Conditional statements within expressions

In Linx, when making decisions to set values, you typically use a IfElseFNC to create a condition and then using a SetValueFNC you set the value appropriately.

Lets use the example of deciding whether or not an integer is greater than zero, if it is then a string type will be set to “Positive” and if not the type will be set to the text “Negative”.

You can achieve the above result by using the below approach:

However, you are also able to create a condition exactly like the IfElse, except you can do straight in the expression editor.

A conditional statement in a Linx expression takes the following structure:

{condition to evaluate to a boolean type} ? {value if true} : {value if false}

The character ? indicates the end of the condition and the start of the ‘if true’ statement. The : character indicates the start of the ‘else’ statement.

So in our case, we can use the below expression to set the initial value of ‘MyMessage’:

= MyNumber > 0 ? "Positive" : "Negative"


You are even able to nest conditions.

Lets add another condition that executes if the first condition is false, this nested condition will check if the number is equal (==) to 0, if so then the text “Neutral” will be the result, if not the the word “Negative”.

{condition1} ? {value if condition1 true} :  {condition2} ? {value if condition2 is true} : {value if condition2 is false} 

To demonstrate, lets check if the number is 0 and set the value as “Neutral”:

This approach is very useful when setting or evaluating individual values that you don’t need to execute specific function logic for.