Show in Frame No Frame
Up Previous Next Title Page Index Contents Search

6.3.2 Foreach loop

The main control structure of a generator loop is the foreach loop, which iterates over elements directly contained in that graph: objects, or roles, relationships and ports in bindings. In a typical generator the foreach clause selects all such elements of the specified type to be operated on. The operations that will be performed on the retrieved elements are written within the curly brackets, {}.
foreach .objType
{ /* Operations for the elements */ }
A foreach loop is most often found as the outermost loop at the top level of a generator. It can only be used when the element stack contains a graph; the innermost graph will be used (level numbers can modify the stack level from which the search starts, see Section 6.1.9). The element type to be looped over must be an object, relationship, role or port: graph and property are not appropriate. There can only be a single type clause rather than a chain of them (use a do loop instead for a chain). The type clause can be a complex type pattern as in Section 6.1.6, and the resulting elements can be filtered with where and unique and ordered with orderby as in Section 6.3.4.

Show in Frame No Frame
Up Previous Next Title Page Index Contents Search