|
|||||
Looping constructs | |||||
Related Syntax |
To have an OmniMark program perform an action or set of actions repeatedly, you will need to create a looping construct of some sort. OmniMark provides three types of looping constructs, repeat
, repeat over
, and repeat scan
.
The simplest is a repeat...again
. This form of loop will simply repeat the execution of the actions it contains, until an explicit exit
action is encountered in the loop.
process local counter count1 repeat output "count1 is %d(count1)%n" increment count1 exit when count1 = 4 again
This repeat...again
will execute the output
action until the counter "count1" equals 4 at which point the exit
action will execute and the loop will terminate, resulting in the following output:
count1 is 1 count1 is 2 count1 is 3
The second type of looping construct is a repeat over...again
. This type of loop is used to iterate over a shelf and perform a set of actions on each item that exists on that shelf. For example, the following program will output the values of each item contained on the stream shelf "names":
global stream names variable initial {"Bob", "Doug", "Andy", "Greg"} process repeat over names output names || "%n" again
repeat over
loops can be used to iterate over any type of shelf, and the loop is terminated after the last item on the shelf has been processed.
Related Syntax repeat repeat over |
---- |