This activity is used to create a set of repeating actions. It basically replicates while loops used in programming.
Structurally it is different from any other activities. 'Do-while loop' itself is not a standard action block. By default this activity consists of two blocks: 'If... then' block and 'Assign value to variable'. The former checks a specific condition. If this condition is true, the body of the loop is executed. The latter lets you save the result and reuse it in the loop if required.
This is how it looks by default. In order to make it work as intended, some additional setup is required. We will review it in 'Parameters' and 'Usage' section below.
The default composition of 'Do-while' activity
The only parameter here is Condition. Considering the nature of this activity, it is actually a part of the 'If...then' block which appears when adding 'Do-while loop' to the workflow. It is required to fill. The body of the loop will be executed based on this parameter. The expression must return either True or False.
For example, if we set the condition like this, then the loop will be executed only when it is True, that is when the variable a is greater than five
Let us have a look at how a complete workflow could look like.
Loops imply iterations that need to be counted somehow. In strandard while loops it is typically done through special 'counter' variables that are incremented with every new step. Here we are going to implement such a loop.
In this example we increase the counter with every iteration and print the result in the console. As soon as it reaches 5, the loop is stopped.
A workflow containing a loop
And this is how the blocks parameters are set in this case. They are represented according to their order in the image above.
This is the counter variable. It will be incremented with each iteration
The condition to check. Once the value of the counter variable reaches 5, the loop is stopped
That is how we set the message in the 'Console log' activity. A message is printed, then the counter value is displayed
The last block increments the counter variable with each iteration
And here is the result. The execution stopped as soon as the condition is not True anymore