The For Loop

for iterator [do]
  {instruction}
loop


The nested sequence of instructions is carried out once for every value specified by the iterator. The variable (or variables) introduced by the iterator is entered into a name space local to the for instruction. Therefore, the following writes 2 3 1 to the standard output stream:
  i : Integer := 1
  for i in [2..3]
     put i &
  loop
  put i
Note that variables defined inside the body of a for-loop are local to the loop. For example, the following writes 2 3 1:
  i : Integer := 1
  for j in [2..3]
    i : String := mkstr(j)
    put i &
  loop
  put i

Herman Venter

This is Slim documentation as snarfed on 27 May 1999 by dB.