Loading

WHILE


control
Since v1.0.0
Available on all platforms
See also

Configuration parameters


The WHILE function implements a while loop. It takes two macros as arguments from the stack: the condition macro to evaluate and the macro to execute while the condition is true.

If one iteration takes too long (warpscript.maxloop) the loop will be killed.

Since Warp 10 2.4.0, you can force WHILE to push an index (iteration count, start at 0) on the top of the stack before calling the macro.

Signature

Examples

5 <% DUP 1 > %> // Condition macro: top of the stack bigger than 1 <% // Exec macro: we say it's bigger than 1 and we decrement counter by 1 DUP 1 - 'index' STORE 'bigger than 1' $index %> WHILE 'smaller or equal to 1' // Then the last number found should be smaller or equal to 1