Loading

FORSTEP

control
Configuration parameters

The FORSTEP function implements for loop with an index step. It takes four arguments from the stack: the initial and the final values of the loop index, a macro step to evaluate after each iteration and an other one to be executed at each iteration.

For each iteration the loop index is put on top of the stack, and the exec macro is then called. Since Warp 10 2.4.0, you can override this behaviour with a boolean.

FORSTEP is available since version 1.0.0.

See also

Signature

Examples

// Macro that squares the value on the top of the stack <% 2 ** %> 'SQUARE' STORE // Macro step, increasing index by two <% 2 + %> 'STEP' STORE // FOR from i=0 to i=20 with a step of 2generate i^2 0 20 $STEP $SQUARE FORSTEP