Control Structures

repeat with

Supported By

Syntax

repeat with variable = start to finish [step increment]
   statementList
[(lastly|then|else)
   statementList]

end repeat

repeat with variable = start (down to|downto) finish [step decrement]
   statementList
[(lastly|then|else)
   statementList]

end repeat

Variable is a variable name or an expression yielding a variable name. Start, finish, increment, and decrement yield numbers.

Example

repeat with x = 1 to 10
  put x
end repeat

Description

The repeat with structure causes all the statements inside to execute in a loop in which variable contains the value start at the beginning of the loop and is incremented by increment (or decremented by decrement) with each iteration of the loop. Execution ends when variable contains the value finish. If no increment (or decrement) is given, it is assumed to be 1.

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.

Notes

Variable can be any expression as long as it yields a valid variable name. In the following example, the variable actually used is called a:

put "a b c" into x
repeat with word 1 of x = 1 to 10
  put a
end repeat

Compatibility

HyperTalk does not support the downto keyword. Use down to instead.

HyperTalk does not support the step keyword, and only allows integer values. XION allows any real numeric value.

See Also

repeat, repeat for, repeat until, repeat while