Flow Control

Overview

Task flow control is based on the following elements:

On the Wiki there is a detailed example of processing a file contents [External Link].

Tip: if you accidentally create a task that never ends when experimenting with loops, use the KillAll button in the Task Edit screen to end it manually.

Conditions
Every action can have a condition associated with it (do this in the Action Edit screen). If the condition does not match, the action will be skipped.

A condition consists of an operator ('equals' etc) and two parameters. The possible operators are:

Expressions which are not mathematically valid e.g. I Am The Walrus > 5 give a warning and evaluate to false when used with a mathematical operator.

Until Loop

Goal: perform a Task X until some condition is met (at least once)

1. Action One
...
2. Action Two
...
3. Goto Action
1
If %QTIME < 20
Return to action 1 if runtime < 20

Result: Action One and Action Two are performed until %QTIME contains the value 20 or more i.e. until the task has been running for 20 seconds.

While Loop

Goal: perform a Task X while some condition is met.

1. Stop

If %FRUIT != Apple
Stop task if it's not crunchy, otherwise go to next action
2. Action One
...
3. Action Two
...
4. Goto Action
1
Go back and see if we're still crunchy

Result: Action One and Action Two are performed while %FRUIT contains the value Apple.

Counter Loop

Goal: perform a Task X a set number of times.

1. Variable Set
%COUNT, 0
Initialize the counter
2. Action One
...
3. Action Two
...
4. Variable Add
%COUNT, 1
Add one to %COUNT
5. Goto Action
2
If %COUNT < 10
Return to action 2 if count < 10

Result: after initialization of %COUNT to 0, the task loops around the actions from 2-5 until %COUNT reaches 10, at which point the condition on the Goto Action fails and the end of the task is reached.

If / Then / Else Condition

Goal: perform certain Tasks if conditions are met, otherwise perform a different task.

1. Perform Task
X, Stop = On
If %FRUIT = Apple
Stop and do task X if crunchy fruit, otherwise next action
2. Perform Task
Y, Stop = On
If %FRUIT = Banana
Stop and do task Y if squashy fruit, otherwise next action
3. Perform Task
Z
Other fruit: task Z

Subroutines

To call another task, use the Perform Task action. To use it as a subroutine, you just need to ensure that the priority of the calling task is less than the priority of the called task (more info: scheduling).

Scheduling

Be sure to read the information on Task Scheduling if you plan to have tasks sticking around for a while in a loop.