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
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.
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