repeat over
Full Description
swirl
Syntax
  repeat over shelf-type? shelf-name (& shelf-type shelf-name)?
     local-declaration*
     action*
  again


Purpose

A special form of the repeat action used to process successive items on a given shelf. The actions are repeated once for each item on the shelf.

References to the shelf name are interpreted as though followed by item 1 during the first iteration, by item 2 in the second iteration, and so forth.

repeat over can process the items on several shelves in parallel. The first item on each shelf is processed before the loop moves to the second item, and so on, until all items on all shelves have been processed.

The keyword and can be used in place of "&".

In a repeat over action, it is often useful to know whether the loop is at the first or last iteration. Two predefined switches provide this information. The switch named #first is active only on the first iteration. The #last switch is active only on the last iteration. They are both active on the only iteration over a set with one member. These two switches are read-only; they can be tested in a switch test, but they cannot be explicitly activated or deactivated. When repeat over loops nest, each instance has its own #first and #last switches.

You can also ask for the index of the current iteration by accessing the predefined counter #item. It can be used in numeric expressions or in format items that format counters. When repeat over loops nest, each instance has its own indices.

repeat over can be used to process the following:

  • successive tokens from a list-valued attribute
  • successive attributes of a currently open element
  • the current element stack
  • the referents shelf

If a repeat over action iterates over a set of attributes or over the tokens of an attribute, or if an attribute or attribute token is identified by a using prefix, then all text written to the #markup-parser stream will be "buffered" in the same manner until the action completes.

Can you add an item to a shelf inside a repeat over loop? Yes, but only at a position greater that the size of the shelf when the loop began. The number of iterations in the loop is determined before the first iteration, and adding more items to the shelf from within the loop will not change the number of iterations being performed.

Can you remove items from a shelf within a repeat over loop? Yes, but only items that were added within the same loop.

Copyright © OmniMark Technologies Corporation, 1988-1998.