swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
control structure  

repeat for

 
 

Syntax

repeat (for integer name)? 
   (from numeric expression)?
   (to numeric expression)?
   (by numeric expression)?
actions
again


Purpose

You can use a repeat for loop to repeat a loop a certain number of times. A repeat for loop has a control variable which has a different value for each iteration of the loop. You can specify the start and end values of the control variable and the steps by which it will be incremented or decremented each time. All these parameters can be omitted, and the appropriate defaults will be applied.

Here is a simple repeat for that repeats 10 times:

  process
     repeat for integer i from 1 to 10
        output "d" % i || " "
     again

Since the default value of the from clause is 1, you can omit the from clause from the program above:

  process
     repeat for integer i to 10
        output "d" % i || " "
     again

You can use the by clause to specify the amount by which the control value is incremented:

  process
     repeat for integer i to 100 by 10
        output "d" % i || " "
     again

The above program prints out:

  1 11 21 31 41 51 61 71 81 91

Notice that the control variable does not always reach the value of the to clause. The loop exits if the next value of the control variable would exceed the value of the to clause.

To make the above program count from 10 to 100, you would need to add a from clause:

  process
     repeat for integer i from 10 to 100 by 10
        output "d" % i || " "
     again

You can change the direction of the loop's progress by specifying a negative value for the by clause.

  process
     repeat for integer i from 100 to 10 by -10
        output "d" % i || " "
     again

A repeat for loop will exit under any of the following conditions:

If you omit any of the from, to, and by values, the default values will be used. The defaults are:

In all other respects, a repeat for loop behaves like a regular repeat loop.

    Related Syntax
 
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.