Creates a loop that executes activities declared inside the DoWhile activity while the condition is met.
- Condition - The condition to be analyzed after executing the sequence within the body before repeating the loop.
- DisplayName - Renames the activity.
- Rename the initial sequence to Main Sequence.
- Drag a DoWhile activity inside the Workflow area.
- By itself, a DoWhile activity could only hold one activity inside its body. Since we would need multiple activities within the body, let us add a Sequence activity to the Body section of DoWhile activity. Rename the Sequence to DoWhile Sequence.
- Create two variables called ctr and num with Int32 as its Variable Type, Main Sequence as their Scope, and 1 as their default value.
- Inside the DoWhile Sequence, add a Write Line activity.
- In the Write Line Text field, type num.ToString. This writes the value of num in the Output panel each time it is incremented.
- After the Write Line activity, add an Assign activity.
- In the Assign activity's To field, input the num variable. In the Assign activity's Value field, type num + 1. This will increment the value of the variable by one.
- After the first Assign activity, add another Assign activity under it.
- In the Assign To field, input the ctr variable. In the Value field, type ctr+1. This will increment the value of the variable by one.
- In the Condition field of the DoWhile activity, type ctr<5. The Sequence inside the body of the loop is repeated until the value of ctr is bigger than or equal to 5.
The use case should look like the following screenshot:
Application of Do While activity
The output should look like this in the Output panel:
The expected results to be shown on the Output panel