Skip to main content

Conditional If/Then/Else Statement

Using Variables in Conditions

You can use variables in your conditional expressions:

Nested Conditionals

XanoScript supports elseif for multi-branch logic. You can use if, one or more elseif, and an optional else block within a conditional statement.
You can use one if, zero or more elseif, and an optional else block in a conditional statement. For more than two branches, prefer elseif over nested conditionals for clarity.

Switch/Case Statements in XanoScript

XanoScript supports switch statements for multi-branch logic. Each switch can have multiple case blocks and an optional default block. Each case must end with a break statement. Example:
Notes:
  • Each case must be followed by a break statement.
  • The default block is optional and will run if no case matches.
  • You can use variables or expressions in the switch value and case comparisons.
XanoScript supports elseif for multi-branch logic. Use elseif for clarity when you have more than two branches. switch statements are also supported as shown above.