For Loop

For loops are used to iterate through each row of a given variable, based on a user-defined condition and increment. The for loop will continue to run repeatedly until the user-defined condition returns as false. The for loop is made up of these three stages:

  1. Initialization
  2. Condition
  3. Incremental count

During the first stage, the loop is executed from the initial value that was assigned to the loop - this is the initialization. During the second stage, the condition that was supplied is evaluated; if the condition is not met, the loop will stop running. If the condition not met, the loop will continue to run, iterating through the initialization value according to the given increment (stage 3). Once this third stage is complete, the loop will begin again. The loop will continue to run until the given condition resolves to false.

For Loop Properties

Display Name

The default display name of the for loop node is For Loop 1. Any subsequent for loop nodes are named according to this naming convention, with the appropriate numeric suffix, e.g. 'For Loop 2', 'For Loop 3', etc.

You can change the for loop node name from directly from this field.

Description

You have the option to add a description to each for loop node; this can be a useful way of documenting the node for yourself and other users.

Initialization

Choose the required variable and set the initialization value by entering an integer or writing a PQL expression.

Condition

Write a PQL condition that, when true, will cause the loop to run. When this condition is false, the loop will stop running.

Increment

Set the increment by which to iterate though the variable. Start by selecting the variable (this should be the same variable that was provided for the initialization value. The increment value can be an integer or a PQL expression.

PQL Expressions

The initialization, condition, and increment values can be static integers, or dynamic PQL functions. You can construct a PQL expression by writing or pasting it directly into the field, or by opening the PQL Editor.

The for loop supports the use of the 'Common' PQL functions; when you open the PQL Editor, the Common PQL functions will be exposed, along with any variables that you've created within the flow.

To open the PQL Editor, click the PQL icon from the value's field.

  • Click here to review documentation of the PQL Common functions.
  • Click here to learn more about the PQL editor.
  • Click here to learn about PQL syntax.

Example

In the example below, the loop will iterate through each row of the Index variable, starting from 0 and with an increment of 1. When the value of the Index variable is no longer smaller than 5, the loop will stop running.