Loops

- iteration

simple

Primitive Action
Forever [list]
Repeat n [list]
DoUntil [list] [cond]
DoWhile [list] [cond]
While [cond] [list]
Repeat instructions in list forever. STOP button to cancel.
Repeat
instructions in list n times.
Do instructions in list until condition is true.
Do instructions in list while condition is true.
While condition is true, do instructions in list.
For [x a b s] [list]
ForEach var [list1] [list2]
RepCount
For x from a to b, with optional step s, do instructions in list.
For each element of list 1, do instructions in list 2.
Return the number of times a repeat loop has executed.
Stop
StopAll
Output xx
Stop and break out of procedure or loop.
Stop and break out of all procedures or loops, end program.
Break out of procedure or loop with output value xx.

Note

  1. RepCount must be within a repeat loop. It returns the number of times the loop has executed, starting with 1.
    So this prints 7 times table. Repeat 12 [Print 7 *RepCount]
  2. In For loops, the step value is optional. If no value is given, a default value of 1 is used.
  3. If you need to evaluate start, end or step values when creating a For loop, use: List (For "A :Start :End :Step)
  4. Repeat loops must be repeated a positive integer number of times. This includes 0, in which case the loop is skipped.
  5. Use ForEach like this: ForEach "i [a b c d e] [Print :i]
  6. Alternative form for DoUntil is RepeatUntil
  7. Alternative form for DoWhile is RepeatWhile