Condition Keywords

Keywords that allow execution based on a condition.

There are 3 condition keywords. These run a statement based on a condition.

Condition statements are designed to be followed by a block section.

If

If statements run a statement if and only if a check passes.

if %check% %then%
if 5 == 5 /print hello

result = true
if result {
    /print hello
}

if "hello" == "hello" /print hello

If statements will conform the check result to a boolean (true/false) value.

True
False

true

false

Any non-zero number.

A zero value.

Any non-null object.

null

This means that statements like the following are valid and correct.

if "hello" /print ok
if 1 /print ok
if true /print ok

While

While statements run a statement as long as a check passes.

While statements will conform the check result to a boolean (true/false) value.

For

For statements run a statement once for every value in a collection of values.

Although there is no explicit check, a for statement is a special while statement internally.

For statements are useful for iterating (looping) over a number of values.

Last updated