swirl
Guide to OmniMark 7   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
   do when, do unless
   repeat over, #item, #last, #first
   repeat scan
   repeat over referents
   repeat over current elements
   repeat over data-attribute
   repeat over attributes
   repeat over data-attributes
 
 
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:43 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.