How to break a While loop/Do while loop

studio
uipath
#1

How to break a While loop/Do while loop. Break activity is not working, seems it will work only for for each.

2 Likes
#2

Hello,

Maybe this will help,

Regards

1 Like
#3

Hello!

A While Loop/Do Loop, must have a condition to met. Try to do a If when you need to exit the loop which will give the condition to exit the loop :slight_smile:

Regards,

2 Likes
#4

I am clueless as to why the Try Catch method would not be considered as good practice.

Essentially you catch an exception (maybe element doesn’t exist, row end, pagination end etc etc) and update a value that does not satisfy the Do WHile/WHile VB Expression, eventually ending it. (An exception is basically developer defined and there is no hard and fast rule in that regard)

There have been requests for ‘Continue’ options and break options for While (not so relevant), but a workaround that helps you achieve the objective without shortcomings can also be considered.

Tell me what you think.

#5

What about forcing to meet the condition.

For example if the condition is x < 10, then you can assign x = 10 when you want to end the loop

#6

I think that the TC (TryCatch) will work in some cases as a solution

The problem is that if an error is found in a step inside the loop you might want a different behavior rather that continue after the loop. For example, we have TC that restarts the process if an error is found to prevent to stop production.

1 Like