WHILE
WHILE
creates a loop that continue to repeat whilst the given <condition>
is TRUE
.
Also supports an optional parameter for a new variable that keeps count of the current iteration, which is zero based.
Syntax
WHILE <optional: count declaration>,<condition>
<codeblock>
- Numeric Conditional
- String Conditional
- Counter
DucklingScript
VAR a 10
WHILE a!=15
VAR a a+1
$STRING a
Compiled
STRING 11
STRING 12
STRING 13
STRING 14
STRING 15
DucklingScript
VAR a ""
WHILE a!="eee":
VAR a a+"e"
$STRING a
Compiled
STRING e
STRING ee
STRING eee
DucklingScript
VAR a 10
WHILE counter,a!=15
VAR a a+1
$STRING a*counter
Compiled
STRING 0
STRING 12
STRING 26
STRING 42
STRING 60
warning
Please note that there is a limit to while loops; while loops will eventually error if they run too many times.