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

repeat, again, exit

 
 

Syntax

repeat
   local-declaration*
   action*
   exit? condition?
again


Purpose

repeat is used to create a loop. All actions between repeat and again are repeated until the loop is terminated by an exit statement. Execution then resumes after the again.

A repeat loop constitutes a local scope, so local variables declared within the loop are local to the loop. In fact, they are local to each iteration of the loop, which means their values are re-initialized on each iteration. They are not, therefore, good candidates for creating exit conditions or maintaining data across iterations of the loop. In the following program, the output shows the value of "i" going up each time, but the value of "j" staying the same:

  process
     local integer i
     repeat
        local integer j
        output "i=%d(j) : j=%d(i)%n"
        increment i
        increment j
        exit when i > 20
     again

Within a function you can use return instead of exit to terminate a loop so that:

  function ...
     repeat
        ...
        exit when x > 5
     again
     return y
can be replaced by:
  function ...
     repeat
        ...
        return y when x > 5
     again

    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.