Loop inside another loop not working

Hello. I’m trying to create a mobile number generator that generates numbers for any country chosen. The generated number is working, however, the number of times to generate a given number does not work while using a While activity to loop. The generated number is the same every time. Please download the demo to investigate more. Thx.

Main.xaml (11.4 KB)

Hey Karl.

You’re not resetting “i”, so it generates a number on the first loop, then for each subsequent loop, the bot sees that “i” already <= 5 and doesn’t proceed to enter that do while.

Resetting “i” to 0 before the embedded do while should get you past this.

You’ll also need to do the same and reset strBuilder at the same point otherwise it results in 5 numbers being appended each loop.

Cheers,
Josh

Hello @private_matter

If youa re using the while loop then you have to use the counter variable.

suppose if the condition is i<10

i is an integer variable declared as 0 and in the while loop as the last step you need to increase the value of i.

Use assign activity-> i=i+1

Thanks

Hi @private_matter ,

Kindly check this updated workflow.
Main.xaml (15.9 KB)

1 Like

That works pretty well even though its using a different formula and even with no variables needed except for the strBuilder. I think I’ll use your solution method. Great job @ahmad.sultan! I’ll have to learn more about using formulas.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.