"FOR" is the most important generator command. It is used to navigate through the hierarchical structure of input data.

Syntax
<for>variable iterator[@objname][<asc>sort expression][<desc>sort expression][<dist>]<where>{boolean_expression}[<set>set environment variable<div>divider<wrap>wrap[<@>container]<begin>body<endfor>
for each element in iterator collection of objname object matching filter expression generates code based on body expression
Example of usage
To show list of classes in a UML package use the following code
<for>x classes<begin>Class %x.name%
<endfor>

Hierarchical browsing
Hierarchical browsing is the core idea of MGL generation. Each hierarchical structure can be passed by sequence of encloded iterators. I.e. if we want to generate list of methods for all classes in the package we start with iteration through list of package classes; for each class we print class name and iterate throug list of class methods; for each method we print method name and iterate through list of parameters; for each parameter we print parameter name and data type. The assumption is that generated source code can be represented as hierarchical structure resembling structure of the UML class model.
Here is whole hierarchy of UML elements supported by NewGen
Note, that hierarchy can have endless circular connections through class-association-class link. Generator has limit of maximum iteration deepness. By default it is 20 levels deep.
Iteration is executed with <FOR> command. The above example can be coded as
<for>c classes<begin>
class name = %c.name%
<for>m methods<begin>
     method name = %.m.name%
<for>p params<begin>
          parameter = %p.name% of %p.type% type
<endfor>
<endfor>
<endfor>