Difference between revisions of "While Node"

From PresenceWiki
Jump to: navigation, search
(While Node)
(Using the While Node)
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
Here is an example of a pseudo-Task that uses a While Node:
 
Here is an example of a pseudo-Task that uses a While Node:
  
http://www.international-presence.com/wikidocs/images/while_task.png
+
[[file:while_task.png]]
  
 
This example performs the following:
 
This example performs the following:
Line 19: Line 19:
 
As long as the While Node test conditions evaluate to true the following Nodes will be executed. As soon as the test evaluates to false it will cede execution. This is an example of Iterative [[Execution Path]].
 
As long as the While Node test conditions evaluate to true the following Nodes will be executed. As soon as the test evaluates to false it will cede execution. This is an example of Iterative [[Execution Path]].
  
While Node Iteration can be slow on limited CPU/memory machines due to nature of the [[Presence Context]] being cloned on each iteration, if you encounter this, you might want to use a different strategy such as creating a temp table in a database and then use the built in iteration functionality of Presence (see [[Data Table]]).  
+
While Node Iteration can be slow on limited CPU/memory machines due to nature of the [[Presence Context]] being cloned on each iteration and the rule being evaluated at every iteration, if you encounter this, you might want to use a different strategy such as creating a temp table in a database and then use the built in iteration functionality of Presence (see [[Data Table]]). The Built in iteration functionality will only use one rule evaluation so it is much faster.
  
 
=== Using the While Node ===
 
=== Using the While Node ===
Line 25: Line 25:
 
Drag the "While" Task Element from the toolbox onto your Task Edit View. You will then be presented with the following Dialog Box:
 
Drag the "While" Task Element from the toolbox onto your Task Edit View. You will then be presented with the following Dialog Box:
  
http://www.international-presence.com/wikidocs/images/while_dialog.png
+
[[file:while_dialog.png]]
  
You can create conditions by dragging the Variable or Column names from the left hand panel into the main panel. When doing so you will be asked to input the condition:
+
Columns are not shown in the above window as the while node only evaluates variables for the rules to improve performance.
  
http://www.international-presence.com/wikidocs/images/while_condition_dialog.png
+
You can create conditions by dragging the Variable from the left hand panel into the main panel. When doing so you will be asked to input the condition:
 +
 
 +
[[file:while_condition_dialog.png]]
  
 
You can add one or more conditions, and they can be arranged in nested groups separated by and / or logic. This allows you to create a complex condition such as:
 
You can add one or more conditions, and they can be arranged in nested groups separated by and / or logic. This allows you to create a complex condition such as:

Latest revision as of 10:49, 3 September 2015

While Node

In Presence Tasks, 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 While Node serves this purpose - it will continue to repeat execution of subsequent Nodes as long as the conditions specified are met. This Node is most useful if you wish to repeat a process a certain number of times, or as long as certain other conditions remain true.

Here is an example of a pseudo-Task that uses a While Node:

While task.png

This example performs the following:

  1. Start of Task
  2. Set Task Variable ${count} to 0 (zero).
  3. Tests ${count} value is less that 100
  4. Increments ${count}
  5. Runs a repetitive Task (100 times).

As long as the While Node test conditions evaluate to true the following Nodes will be executed. As soon as the test evaluates to false it will cede execution. This is an example of Iterative Execution Path.

While Node Iteration can be slow on limited CPU/memory machines due to nature of the Presence Context being cloned on each iteration and the rule being evaluated at every iteration, if you encounter this, you might want to use a different strategy such as creating a temp table in a database and then use the built in iteration functionality of Presence (see Data Table). The Built in iteration functionality will only use one rule evaluation so it is much faster.

Using the While Node

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

While dialog.png

Columns are not shown in the above window as the while node only evaluates variables for the rules to improve performance.

You can create conditions by dragging the Variable from the left hand panel into the main panel. When doing so you will be asked to input the condition:

While condition dialog.png

You can add one or more conditions, and they can be arranged in nested groups separated by and / or logic. This allows you to create a complex condition such as:

Country = USA

AND

State = Nevada

AND (

City = Las Vegas
OR
City = Boulder

)

More detailed information on Rules and Conditions can be found in the Rules discussion.

See Also

Task Elements > Flow Control Task Elements > While Node

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