The statement FOREACH WIZARD enumerates selected Sections and Text Blocks in a Content Wizard. You can use nested FOREACH WIZARD constructs to enumerate the contents of those Sections.
Note
ITP Models using this feature can be created with ITP/Workstation, but to run a model containing this feature, you will need ITP/Server or ITP/OnLine Server.
Definition:
FOREACH WIZARD Element IN WIZARD id
DO
ITP-model part
OD
The statement FOREACH WIZARD Element IN WIZARD id enumerates the top level Sections and Text Blocks the end user has selected in the last presented Content Wizard dialog with the label id. If no such Content Wizard was presented to the end user a fatal error is reported.
FOREACH WIZARD SubElement IN Element
DO
ITP-model part
OD
The statement FOREACH WIZARD SubElement IN Element enumerates all Subsections and Text Blocks the end user has chosen within the Element. You can use this statement only within the part DO … OD of another FOREACH WIZARD statement, and the Element must be the loop variable of such a statement.
The loop variables Element and SubElement are automatically declared and available within the loop DO … OD. You can choose the names, but they must match the rules for valid FIELDSET names. These loop variables behave for all intents and purposes as read-only FIELDSET variables. You can copy Element and SubElement to regular FIELDSET variables.
You can use the following fields:
Type
The field Type indicates the object type of the current element. This field can have the following values:
"section" - the object is a Section."textblock" - the object is a Text Block or a list of Text Blocks."group" - the object is a Group."list" - the objects is a Data Definition group representing a DATASTRUCTURE, an ARRAY of DATASTRUCTUREs, or an ARRAY of FIELDSETs."item" - the object is an iteration within the Data Definition group. These objects only occur within "list" elements. Name
If the current element is a Text Block, this field contains the name and path to the Text Block as specified in the Content Wizard. If the element allows multiple selections, this field contains a comma-separated list (CSV format) of Text Blocks. For other elements this field contains the name of the element as shown in the Content Wizard.
TextBlock
This field contains the name and path to the Text Block containing the effective content of the element. If the element allows multiple selections, this field contains a comma-separated list (CSV) of Text Blocks. If the element is editable, this field will contain a reference to the edited Text Block(s).
The content of this field can be passed directly to the statement TEXTBLOCK to produce the content of the Text Block(s).
This field is empty if the current element is not a Text Block.
MinElements and MaxElements
These fields contain the minimum respectively maximum elements that can be chosen in the Group. These fields are empty if the current element is not a Group.
Wizard
This field contains the name of the Content Wizard.
QForm
This field contains the name of the QForm that was defined at the Section or Subsection. This field is empty if the current element is not a Section.
WizardQForm
This field contains the name of the QForm that was defined at the top level of the Content Wizard. This field is empty except for top-level Sections and Groups.
Editable
This field contains "Y" if the Text Block could be edited during a Content Wizard run. It contains "N" if the Editable option was not selected for the Text Block in the Content Wizard Editor.
Count
This field contains the total number of elements in a Data Definition group. This field is present in both "list" and "item" elements.
Current
This field contains the sequence number of the current iteration in a Data Definition group. This field is present in "item" elements.
Member
This field contains the DATASTRUCTURE member over which the Data Definition group is enumerating. This field is present in "list" elements.
Path
Internal path in the Data Definition which indicates which FIELDSETs in the Data Definition are currently visible. This value can be passed to the TEXTBLOCK statement to apply the correct data to the Fields in the Text Block(s) and associated QForm.
Note
The content of the Path field is intended for internal use only and only remains valid until the next time a Content Wizard with the same ID is presented or the model ends. Its value can be copied to variables but not stored externally. Any changes or manipulations will be rejected with a Fatal Error.
Any use of the statement TEXTBLOCK to insert a Text Block within a FOREACH WIZARD loop will by default apply the context of the FOREACH loop to the Text Blocks and associated QForm. Any Field Sets used in the Text Block and QForm are resolved in the context of the Data Definition first and only if these cannot be found Field Sets are searched outside the Data Definition.
Text Blocks within a Data Definition group will always refer to the Field Sets within the current iteration of the Data Definition group. This will automatically handle repeating Text Blocks.
The model developer can use the keywords DATA_DEFINITION and PATH on the statement TEXTBLOCK to either disable the context handing within a FOREACH WIZARD loop, or to simulate this behavior outside the loop FOREACH WIZARD by keeping track of the Path field associated with the Text Block.
Example:
# BEGIN
WIZARD "myID"
NAME "my wizard"
FOREACH WIZARD Element IN WIZARD "myID"
DO
IF Element.Type = "section" THEN
#
Wizard @(Element.Wizard) [@(Element.WizardQForm)]
Section @(Element.Name) [@(Element.QForm)]
#
ELIF Element.Type = "textblock" THEN
TEXTBLOCK VAR Element.TextBlock
FI
FOREACH WIZARD SubElement IN Element
DO
IF SubElement.Type = "section" THEN
#
SubSection @(SubElement.Name) [@(SubElement.QForm)]
#
ELIF SubElement.Type = "textblock" THEN
TEXTBLOCK VAR SubElement.TextBlock
FI
OD
OD
END #
Result (for a sample Content Wizard):
Wizard my wizard []
Section one []
--text block 1.1--
SubSection one.two [qform 1]
--text block 1.2.1--
--text block 1.2.2--
--text block 1.2.3--
SubSection one.three []
Wizard my wizard []
Section two [qform 2]
--text block 2.1--