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.

TrueFalse

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.

Unless something changes to make the check false, a while statement will run forever.

while %check% %then%
var = 0
while var < 5 var = var + 1
while var > 0 var = var - 1

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.

while <values has next element> {
    var = <next element>
    ...
}
for %variable% = %values% %then%
for word = ["hello", "there"] /say {word}

for number = [1, 2, 3] {
    if number > 1 /say the number is {number}
}

for value = values {
    /print {value}
}

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

Last updated