Difference between revisions of "Loop Until"

From PresenceWiki
Jump to: navigation, search
(Created page with "== 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....")
 
(Loop Node)
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
However looping functionality is often desirable, and the Loop and [[While Node|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|While Node]] in that is will only repeat a process <i>n</i> 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.  
 
However looping functionality is often desirable, and the Loop and [[While Node|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|While Node]] in that is will only repeat a process <i>n</i> 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:
+
Here is an example of a Task that uses a Loop Node: [[:File:Loop_Example.zip|Download Task]]
  
 
[[File:loopexample.png]]
 
[[File:loopexample.png]]
Line 11: Line 11:
 
This example performs the following:
 
This example performs the following:
  
# Start of Task
+
1 Start of Task
# Set [[Task Variables|Task Variable]] ${sine_iteration_array} to " " (empty)
+
 
# Set [[Task Variables|Task Variable]] ${sine_array} to " " (empty)
+
2 Set [[Task Variables|Task Variable]] ${sine_iteration_array} to " " (empty)  
# Set [[Variable|Local Visibility]] variable ${iterations} to 360
+
 
# [[Passive Node|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 Variables|Task Variable]].
+
[[File:loop_example1.png]]
# Start the Loop and continue until the internal ${loop.count} variable has reached the ${iterations} (360) value passed in.  
+
 
## Calculates a Sine plot in the local variable ${sine_plot} using the internal counter ${loop.count}
+
3 Set [[Task Variables|Task Variable]] ${sine_array} to " " (empty)  
## Appends the value of the local variable ${sine_plot} to the Task Variable ${sine_array}
+
 
## Appends the value of the local internal variable ${loop.count} to the Task Variable ${sine_iteration_array}
+
[[File:loop_example2.png]]
# Uses the function [[Multi-Column Split|Functions#Multi_Column_Text_Split]] to create a data table (for the Graph Node) from the ${sine_array} and the ${sine_iteration_array}
+
 
# Drops any empty rows (first row is always empty in this example) using the [[Drop Row(s)|Drop Row(s)]] node.
+
4 Set [[Variable|Local Visibility]] variable ${iterations} to 360  
# Creates the Sine graph from the Data Table.
+
 
# Ends the Task  
+
[[File:loop_example3.png]]
 +
 
 +
5 [[Passive Node|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 Variables|Task Variable]].
 +
 
 +
6 Start the Loop and continue until the internal ${loop.count} variable has reached the ${iterations} (360) value passed in.
 +
 
 +
[[File:loop_dialog.png]]
 +
 
 +
** Calculates a Sine plot in the local variable ${sine_plot} using the internal counter ${loop.count} and the function [[Functions#Eval|Eval Function]]
 +
 
 +
[[File:loop_example4.png]]
 +
 
 +
** Appends the value of the local variable ${sine_plot} to the Task Variable ${sine_array}  
 +
 
 +
[[File:loop_example5.png]]
 +
 
 +
** Appends the value of the local internal variable ${loop.count} to the Task Variable ${sine_iteration_array}  
 +
 
 +
[[File:loop_example6.png]]
 +
 
 +
7 Uses the function [[Functions#Multi_Column_Text_Split|Multi-Column Split]] to create a [[Data Table|Data Table]] (for the Graph Node) from the ${sine_array} and the ${sine_iteration_array}  
 +
 
 +
[[File:loop_example7.png]]
 +
 
 +
8 Drops any empty rows (first row is always empty in this example) using the [[Drop Row(s)|Drop Row(s)]] node. [[File:loop_example8.png]]
 +
 
 +
9 Creates the Sine graph from the Data Table.  
 +
 
 +
[[File:loop_example9.png]]
 +
 
 +
10 Ends the Task  
 +
 
 +
This is the product of the task
 +
 
 +
[[File:loopsinegraph.png]]
  
 
Loop Node Iteration is faster than the While Node due to no other rules are being evaluated at every iteration.
 
Loop Node Iteration is faster than the While Node due to no other rules are being evaluated at every iteration.
Line 33: Line 67:
 
[[file:loop_dialog.png]]
 
[[file: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 [[Data Table|Data Table#Implicit Iteration]] for more information.
+
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 [[Data Table#Implicit Iteration|Implicit Iteration]] for more information.
 +
 
 +
The Checkbox "Iterate on duplicate data table values" will process all result sets using [[Data Table#Implicit Iteration|Implicit Iteration]]
 
   
 
   
 
=== See Also ===
 
=== See Also ===
 
[[While Node|While Node]]
 
[[While Node|While Node]]
 
{{FlowControl}}
 
{{FlowControl}}

Latest revision as of 07:00, 7 September 2015

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 |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes



Task Elements | Resources