Conditional Statements

Note: Version introduced the new keyword/construct named elseif, which makes the deeply nested conditional statements more readable.

The conditional support is provided through the if, elseif and else clauses. The format is:

if (boolean_expression) { statement_1: statement_2, ... } [elseif { statement_1: statement_2, ... }] [else { statement_1: statement_2, ... }]

The part inside [ ] is optional; so the if clause may or may not be followed by an else or elseif clause.

The statements inside the { } blocks end with a colon (:). If you want to prevent the output of a statement from showing on the screen, you can put a semi-colon (;) before the colon as normal.

The term boolean_expression is any expression (simple or complex) that evaluates to either true or false. boolean_expression will usually be an expression having one of the comparison operators. It can also have Boolean operators (+, *, ^, ~, ? and ??). If the expression evaluates to true, the code block (the { } block) is executed. Otherwise it is not executed.

For more information on Boolean expressions please visit the Boolean Expressions page.


>> num1 = 10
>> 10.0000
>> num2 = 20
>> 20.0000
>> if (num1 > num2) { "num1 is bigger." : } else { "num2 is bigger." : }
>> num2 is bigger.