Processing Loops

There are occasions in the XML output where it is desired to have multiple occurrences of an element filled in from a lookup for each record in the main file.

To accomplish this in a filePro XML report two labels are required.  The first label is the entry point for the loop that contains the lookup.  The second label is the control label for the loop.  The loop will be executed by filePro as long as the control label evaluates as true and maxOccurs has not been reached for any element within the loop.

The evaluation of values assigned to the tags between to loop start and the loop control labels takes place at the end of each iteration of the loop.

The fpXmap buttons "Loop Start" and "Loop End" are used to insert loop label rows into the cross mapping table.

Note that your processing code should not have an explicit loop coded in it.  Rather, the loop is executed implicitly by the XML export engine.

When the export engine encounters the loop definition, your code is executed as follows:

 There is a new system field, @XL, which contains the XML loop counter.  The first time the loop is executed, @XL has a value of "1".  This value is incremented each time the loop is executed.  This would allow your code, for example, to execute a LOOKUP on the first iteration, and a GETNEXT for all subsequent iterations.

Note that @XL is reset to "1" each time the loop is restarted.  Also, outside of a loop, @XL has a value of zero.