A structure loop is a template file construct which allows you to iterate through the collection of structures that CodeGen has information about. In order to use structure loops you must be generating code based on multiple repository structures at the same time.
CodeGen can process multiple structures in one of two ways:
•Multiple structures can be specified on the command line, after the -s command line option, and the -ms command line option can be used to specify that all of the structures are to be processed together.
•The -file command line option can be used to use a repository file definition as the starting point for code generation, and that file definition can have multiple structures assigned.
Structure loops are delimited by a matching pair of <STRUCTURE_LOOP> and </STRUCTURE_LOOP> tags that surround the template code to be inserted for each structure. The code between the opening and closing tags is repeated for each structure being processed. This code may contain any other tokens.
If a structure loop is encountered in a template when only a single structure is being processed then an error will be generated and CodeGen will stop processing.
Structure loops can contain code that is to be repeated for each structure being processed, and can also contain any other tokens that are valid when processing a single structure. CodeGen simply repeats the code between the opening and closing structure loop tokens the appropriate number of times based on the number of structures being processed, switching structure context as it goes.
There are two types of structure loops, called multi-line structure loops, and in-line structure loops.
Multi-Line Structure Loops
Multi-line structure loops occur when the opening and closing structure loop tags appear on separate lines in a template file, and delimit one or more entire lines of template code, like this:
Multi-line structure loops generate one or more lines of output code for each structure that is processed.
In-Line Structure Loops
In-line structure loops exist when the opening and closing structure loop tags appear on the same line in a template file, and delimit part of a line of template code, like this:
[code] <STRUCTURE_LOOP> code </STRUCTURE_LOOP> [code]
In-line structure loops generate code into the current output line.
Copyright © 2018 Synergex International, Inc.