repeat Statement

Home Scripting Statements repeat Statement

The repeat statement allows you to program loops in your scripts. It comes in two different flavors:

The first variant works with a boolean expression:

repeat while <boolean expression>
  <statements>
end repeat

As long as the expression evaluates as true, the loop is repeated. With every pass of the loop, the expression is evaluated anew. Because the expression is evaluated at the start of the loop, it is possible that the statements inside the loop never execute. On the other hand, be careful to avoid endless loops that can occur if your expression is always true.

The following is a short example of a loop:

repeat while x > 1000
  x = x * 2
  i = i + 1
end repeat