ForLoop

The ForLoop component is a control flow component for specifying iterations. using this component, users can execute code recurrently to perform repeated tasks.

Screenshot

Ports

The ForLoop component exposes Control In, Control Out, Data In and Data Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Must be connected to the Control In port of any other component. The ForLoop component exposes the following two types of Control Out ports.
Control Out Port: Execution control is passed to this port when the index value is equal to the To port value.
Port to iterate in loop: Control is passed to this port for each iteration between From and To values. This port is connected to the Control In port of any other component.
Data In Must be connected to the Data Out port of another component from where data is to be collected. The ForLoop component exposes the:
From: Define the start value of the ForLoop counter.
To: Define the end value of the ForLoop counter.
Data Out Must be connected to the Data In port of another component where data is to be sent.

Properties

To edit the properties of the ForLoop component, in the Properties window, change the required property. You can edit the following properties:

Property Description
Search Search for the respective property.
Delay After Execution Specifies the wait time (in seconds) after the action is executed.
Delay Before Execution Specifies the wait time (in seconds) before the action is executed.
Delay for each Execution (Seconds) Specifies the wait time (in seconds) for each step of the execution until the ForLoop ends.
Increment By Specifies the number which increments the numbers in the From and To boxes in the component.

Example

Let us consider an example of multiplying a number with a selected list of numbers.

Screenshot

To use the ForLoop component:

  1. In the Toolbox, expand Loops.
  2. Drag the ForLoop component and drop it on the design surface.
  3. Double-click on the From textbox and enter a number for the multiplication to begin with.
  4. Double-click on To and the enter a number for the multiplication to end.

    Note

    Users can override the existing data source for both the Form and the To Data In ports.
    To override the existing data source:

    • Right-click on the required Data In port.
    • Click Override and change the data source.

    To learn more about overriding the data source, refer the Override section.

  5. Add an Expressions component for entering the multiplication expression.

  6. To add the Expressions component:

    • In the Toolbox, expand General.
    • Drag the Expressions component and drop it on the design surface.
    • In the edit textbox, enter the mathematical expression. For this example, enter 8*i.
  7. Add a MessageBox Show component to display output of the expressions component.

  8. To add the MessageBox component:

    • In the Toolbox, expand General.
    • Expand the MessageBox component, drag Show component and drop it on the design surface.
  9. Connect:

    • The Control Ports of all the components.
    • The Control out port to iterate the loop of the ForLoop component to the Control In port of the Expressions component.
    • The Data out port of the ForLoop component to the Data In port of the Expressions component.
    • The Data out port of the Expressions component to the Data In port of the MessageBox component.
  10. In the toolbar, click Run.
    The output with the solution of the multiplication expression is displayed. According to the example, the multiplication of 8 from 2 to 6 will be displayed.

    Screenshot

  11. Click OK to view the next result.

    Screenshot