Discussion
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2024-05/1f77a272-b558-4261-964a-0a7d028c27c5.jpg?h=436c2321&itok=Ilx-4hBN)
Pegasystems Inc.
US
Last activity: 1 Nov 2022 8:08 EDT
Robotics Tip of the day: Using a While loop
Tip #28: The WhileLoop component lets you loop repeatedly until a condition is met. This component is new in v22.1.
When you execute StartLoop:
- The While port link is executed. This link is where you test the loop condition.
- If the loop condition is met, execute a Break block and execution continues from the Completed port.
- If the loop condition is not satisfied, execution continues from the Do port.
- The Do port link is executed. When the execution thread ends, execution continues from the While port.
The only way to exit the loop is to execute a Break block, so be sure there is always a Break. Project analysis checks for this condition as well.
The DoWhileLoop works the same as the WhileLoop except the Do link is executed before the While link.
Note: Click here to see the latest Tip of the Day and a list of all prior tips.