This topic provides basic information
about While nodes.
When you create a While node in the flow editor, the flow editor
creates two artifacts: (a) the While node itself; and (b) an initially
empty flow (containing only a Receive node and a Reply node) for the
While node to invoke.
The While node is created in the flow you that are
currently editing. For this While node to function correctly you must
create an ESQL expression in the While node that resolves to a Boolean
true or false value. This ESQL expression serves as the loop condition
for the While loop.
The invoked flow is a normal invoked flow except
for the fact that it is invoked from within the While node rather
than from an Invoke flow node. In the invoked flow you create a sequence
of nodes that perform the operations that you want to be repeated
when the While loop runs. The invoked flow serves as the interior
of the While loop.
When the While node is processed at runtime it performs the following
cycle:
- It evaluates the ESQL expression stored in the While node.
- It takes some action based on the resulting value of the ESQL
expression:
- If the expression resolved to Boolean true in Step 1 then the
While node invokes the invoked flow, waits for it to return from invocation,
and then begins the cycle again starting with Step 1.
- If the expression resolved to false in Step 1 then the While node
does not invoke the invoked flow and instead terminates, with the
flow of control passing out from the output terminal of the While
node.
For the While loop to perform properly you might
also need to set up the following items:
In the flow containing the While node:
- Before the While node is performed:
- Create and initialize any variables that are used by the ESQL
expression in the While node.
- Set up the input parameters for the invoked flow.
- After the While is node is performed, add nodes to do any additional
tasks that need to be done, such as reading the output parameters
from the invoked flow, testing conditions, or storing and processing
data provided by the invoked flow.
In the invoked flow:
- Read the input parameters.
- When it is time to terminate the While loop, modify the value
of a variable or variables so that the ESQL expression in the While
node evaluates to false.
- Store a return code and output data into the output parameters.
- Store any other data into other variables in the variable message.
You can use While nodes and their invoked flows
both in nonterminal applications and in terminal applications.
Also, in terminal applications you can record a repeating sequence
of application screens as a loop. When you record a loop the flow
recorder (host editor) creates a While node and its invoked flow,
populates the invoked flow with nodes to handle the application screens
that you visit, sets up a loop variable and a loop expression, and
performs other tasks (see Recording loops).