Loop

A Loop is used to repeat an Action many times over, it may be a fixed number, i.e. 10 times, or it might be until a condition is reached, i.e. the number of items in an array has reached a specified number.

In Lucid, to use a Loop, first choose 'Loop' from the 'Logic' menu. This will insert a Loop into your Workflow. You may double-click the action to edit it.

There are four main parts to a Loop Action. Setup, Condition, Body and After Loop.

The Loop, like most Actions, also contains a Callback.

Setup

The Setup stage is where you can enter code to be executed before the loop starts, for example to setup a counting variable...

var i = 0;

Condition

The Condition is an expression that determines whether the loop should continue for another cycle, for example...

i < 10

The code above compares the variable i to the number 10, if it's under 10, the loop continues to another cycle, if not, the loop ends.

Body

The body of the loop is what you want to do over and over, it also usually contains a way of advancing a counter, for example...

i = i + 1;

Note : If you do not provide any way of stopping a loop, it could continue indefinitly, and you may need to Force Quit Lucid to stop it.

After Loop

After the loop ends, you may want to do some cleaning up, but you often won't need to enter anything here.