Set conditional statement

if ... then ... else ... end

Use if ... then ... else ... end to specify an if-then-else conditional statement that has Ninox check whether a sequence of statements should be executed (if... then...) or what should happen when the input condition is not met (... else...).

The if statement with comparison operators

The if statement must be an expression that is either true/yes or false/no.

The use of comparison operators, such as greater than (>=), less than (<=) or equal to (=) is also suitable for this purpose.

Depending on the result of the comparison, the further procedure is determined.

Example

Create a Total field (number field type), type the following script in a formula field, and vary the value to Total:

if Total >= 30 then "Card" else "Cash" end

Result: If the entered value in the Total field is greater than or equal to €30, payment is made by Card, otherwise payment is made in Cash.

You don't need to specify an alternative sequence, e.g., an else. This means that a statement is either executed or not.

let paymentMethod := "Cash";
if Total >= 30 then
	paymentMethod := "Card"
end;
paymentMethod

Result: paymentMethod is set to Cash by default. However, if the value in the Total number field is greater than €30, the value for paymentMethod is updated to Card.

Check data field or variable for content

Use null to check whether a data field is empty. So null does not stand for 0, but for empty. Combined with a branch, it allows you to execute a script even when a field is empty.

Example

if Total = null then
	"Please enter an amount!"
end

Result: If the Total field is empty, a prompt ("Please enter an amount!") is displayed.

Last updated