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....")
(No difference)

Revision as of 16:50, 4 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:

Loopexample.png

This example performs the following:

  1. Start of Task
  2. Set Task Variable ${sine_iteration_array} to " " (empty)
  3. Set Task Variable ${sine_array} to " " (empty)
  4. Set Local Visibility variable ${iterations} to 360
  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.
    1. Calculates a Sine plot in the local variable ${sine_plot} using the internal counter ${loop.count}
    2. Appends the value of the local variable ${sine_plot} to the Task Variable ${sine_array}
    3. Appends the value of the local internal variable ${loop.count} to the Task Variable ${sine_iteration_array}
  7. Uses the function Functions#Multi_Column_Text_Split to create a data table (for the Graph Node) from the ${sine_array} and the ${sine_iteration_array}
  8. Drops any empty rows (first row is always empty in this example) using the Drop Row(s) node.
  9. Creates the Sine graph from the Data Table.
  10. Ends the Task

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 Data Table#Implicit Iteration for more information.

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