Loop Until

From PresenceWiki
Jump to: navigation, search

Loop Node

In Presence Tasks, as with While Nodes it is impossible to link a Node into an earlier Node in the Execution Path as this leads to infinite recursion.

However looping functionality is often desirable, and the Loop and While Node serves this purpose - it will continue to repeat execution of subsequent Nodes until the number of iterations has been performed. This Node differs from the While Node in that is will only repeat a process n times. It also makes doing iterative loops easier as you don't have to keep your own counter as you would have to with the While Node.

Here is an example of a Task that uses a Loop Node: Download Task

Loopexample.png

This example performs the following:

1 Start of Task

2 Set Task Variable ${sine_iteration_array} to " " (empty)

Loop example1.png

3 Set Task Variable ${sine_array} to " " (empty)

Loop example2.png

4 Set Local Visibility variable ${iterations} to 360

Loop example3.png

5 Passive Node is to control the Execution Paths so that our loops are done first and the values of the calculation and iteration number is stored in Task Variable.

6 Start the Loop and continue until the internal ${loop.count} variable has reached the ${iterations} (360) value passed in.

Loop dialog.png

    • Calculates a Sine plot in the local variable ${sine_plot} using the internal counter ${loop.count} and the function Eval Function

Loop example4.png

    • Appends the value of the local variable ${sine_plot} to the Task Variable ${sine_array}

Loop example5.png

    • Appends the value of the local internal variable ${loop.count} to the Task Variable ${sine_iteration_array}

Loop example6.png

7 Uses the function Multi-Column Split to create a Data Table (for the Graph Node) from the ${sine_array} and the ${sine_iteration_array}

Loop example7.png

8 Drops any empty rows (first row is always empty in this example) using the Drop Row(s) node. Loop example8.png

9 Creates the Sine graph from the Data Table.

Loop example9.png

10 Ends the Task

This is the product of the task

Loopsinegraph.png

Loop Node Iteration is faster than the While Node due to no other rules are being evaluated at every iteration.

Using the Loop Node

Drag the "Loop" Task Element from the toolbox onto your Task Edit View. You will then be presented with the following Dialog Box:

Loop dialog.png

You can enter a static value, a Data Table Column (:var{COLUMN_NAME}) or a variable (${variable_name}), if you use a Column Name then the loop will iterate over the data table for each unique value in the Column, see Implicit Iteration for more information.

The Checkbox "Iterate on duplicate data table values" will process all result sets using Implicit Iteration

See Also

While Node Task Elements > Flow Control Task Elements > Loop Until

Schedule Nodes | Decision Point Nodes | Start of Task | End of Task | Error Handler
Throw Exception | Passive Node | Log Entry | Sleep For n Seconds | While Node | Loop Node | Exit Loop Node | |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes



Task Elements | Resources