Maestro script while statement

I am having real trouble understanding how to use while statements in maestro script:

3 
begin
  dup
  while
    10
  repeat

I wrote this as a test expecting to see a 3, then 3 values of 10 in the stack at the end.
Instead i get the 3, then a whole load of 10s, and then a stack overflow.
What am I misunderstanding?

Got it! was missing my minus, and need to swap the values in the stack - didn’t realise the while statement uses whatever value is on top of the stack every time through the loop.

3
begin
  dup
  while
    10
    swap
    1 minus
  repeat
2 Likes