contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
control structure   repeat    
  Related Syntax   Related Concepts  

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 reinitialized on each iteration. They are not, therefore, good candidates for creating exit conditions or maintaining data across iterations of the loop. In the follwing program, the output shows the value of "i" going up each time, but the value of "j" staying the same:

  process
     local counter i
     repeat
        local counter 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
   repeat scan
   repeat over referents
   repeat over current elements
   repeat over data-attribute
   repeat over attributes
   repeat over data-attributes
 
Related Concepts
   Looping constructs
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:15 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.