Control Structures

repeat foreach

Supported By

Syntax

repeat foreach variableName in expression
   statementList
[(lastly|then|else)
   statementList]

end repeat

Expression yields a list.

Examples

repeat foreach x in (1,2,3,4,5,6,7,8,9,10)
  put x
end repeat
repeat for each x in words of "1 2 3 4 5 6 7 8 9 10"
  put x
end repeat

Description

The repeat foreach structure causes all the statements inside to execute in a loop with as many iterations as there are elements in the list, with the specified variable containing the first element of the list during the first iteration, the second element of the list during the second iteration, and so on.

In OpenXION 1.3 and later, the statements under a lastly, then, or else keyword inside a repeat structure will be executed when the loop ends, unless the loop has ended because of an exit, pass, return, or throw.

Synonym

repeat for each

See Also

repeat, repeat for, repeat until, repeat while, repeat with