Control Functions
Conditional and control flow expressions.
If Condition
Returns one value if condition is true, another if false.
| Property | Value |
|---|---|
| Category | Control |
| Min Arguments | 3 |
| Max Arguments | 3 |
| Returns | Same type as True/False Value |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Condition | boolean | Condition to evaluate |
| 1 | True Value | any | Value to return if condition is true |
| 2 | False Value | any | Value to return if condition is false |
Description: The classic if-then-else expression. Returns True Value if Condition evaluates to true, otherwise returns False Value.
Example:
If Condition(Amount > 1000, "High", "Low")
→ "High" if Amount > 1000, else "Low"
If Condition(IsVIP, 0.15, 0.05)
→ 15% discount for VIP, 5% for others
If Condition(Stock > 0, "In Stock", "Out of Stock")
→ availability message
Nested If Conditions
You can nest If Condition expressions to handle multiple cases:
Example - Grade Calculation:
If Condition(Score >= 90, "A",
If Condition(Score >= 80, "B",
If Condition(Score >= 70, "C",
If Condition(Score >= 60, "D", "F"))))
Example - Discount Tiers:
If Condition(OrderAmount >= 10000, 0.20,
If Condition(OrderAmount >= 5000, 0.15,
If Condition(OrderAmount >= 1000, 0.10,
If Condition(OrderAmount >= 500, 0.05, 0))))
Example - Status Message:
If Condition(Is Equal To(Status, "Approved"), "Your request has been approved",
If Condition(Is Equal To(Status, "Pending"), "Your request is under review",
If Condition(Is Equal To(Status, "Rejected"), "Your request was declined",
"Unknown status")))
Common Patterns
Default Value for Null:
If Condition(Null(Discount), 0, Discount)
→ returns 0 if Discount is null
If Condition(Null Or Empty String(Title), "Untitled", Title)
→ returns "Untitled" if no title provided
Boolean to Text:
If Condition(IsActive, "Active", "Inactive")
If Condition(IsApproved, "Yes", "No")
Null-Safe Calculation:
If Condition(
And(Not Null(Quantity), Not Null(UnitPrice)),
Multiply(Quantity, UnitPrice),
0
)
Conditional Formatting:
If Condition(
Is Greater Than(Balance, 0),
Concatenate("+", To String(Balance, "C")),
To String(Balance, "C")
)
Range Classification:
If Condition(Temperature > 30, "Hot",
If Condition(Temperature > 20, "Warm",
If Condition(Temperature > 10, "Cool", "Cold")))
Best Practices
Keep Nesting Shallow: More than 3-4 levels of nested If Conditions become hard to read. Consider using a Decision Table for complex multi-condition logic.
Use Meaningful Values: Make the true and false values self-documenting:
// Good
If Condition(IsOverdue, "OVERDUE", "Current")
// Less clear
If Condition(IsOverdue, 1, 0)
Handle Null Cases: Consider what happens if the condition itself might be null:
If Condition(Is True(IsApproved), "Approved", "Not Approved")
Consider Decision Tables: If you have many conditions with different outputs, a Decision Table may be more maintainable than deeply nested If Conditions.