Loading...
 

while

while

while

Stack
Stack Position Description
Stack(In) Top Value
Stack(Out) Top -

With while a cycle started with do ends. The cycle is repeated (with the instruction following do ) if the value on the stack top can be interpreted as TRUE (compare if). The while instruction consumes, i.e. the value on the stack which is evaluated as TRUE or FALSE is taken from the stack.

Example:

The following example adds up the numbers 1 to 10

Var(i, sum)
10 -> i, 0 -> sum
do
  sum i + -> sum
  Decr(i)
  i
while
sum String Attention

Note: Up to and including version 4.4 while only consumed the FALSE value, i.e. when exiting the loop. The value evaluated to TRUE remained on the stack.

Note: Cycles can be nested up to depth 128. Cycles up to and including version 4.4 are only allowed within the definition of new instructions!