Hey Guys
How to increment a count using a for loop? I basically want to increment the count until it reaches not sure how to do this simple action in uipath.
Hey Guys
How to increment a count using a for loop? I basically want to increment the count until it reaches not sure how to do this simple action in uipath.
Declare an integer variable
Use an assign activity to increment the value inside the for loop.
Variable = variable+1
Where do i get the for loop from. There is only a for each loop. In this case, I am not using an array. So how do I do that. Or how do I set an array to size of 10?
If you just want to loop up until a condition - use a Do While or While loop
For a Do While - Your condition will be intCounter < 10
and increment your counter at the end of your sequence.
You can declare an array and in the variables panel you can initialize it default/known size of the array.
New String(10) {}
@bobby
In case of you are using a for each activity:
A bultin feature is doing this for you:
Int32
variable.But maybe you are in process of a different scenario. So just tell us more about it
Hi @bobby
you can also have a look at the Snippet section, there are also some cool stuff to look at.
I tried that and it did not work. The count does not increament. I basically added a do while activity. Outside created an assign with count =0. Inside the do while activity. I placed the activity I want it to process and then after increament the count by doing count = count +1. In the condition I did do this until count = 10. I printed the count and it appears blank
Ah that’s cool. I did not know that was there. I will try that. Thanks.
so your sequence should look like this:
Assign Counter (int) = 0
Do While Counter < 10
Log Message = Counter.Tostring
Assign Counter = Counter + 1
Hey TimK, that works. The thing I did wrong was made the count =10, not less than 10. Why is equal to 10 not right? Sorry, I am confused.
both are correct it depends on what you want the loop to do
the operator < is required to make the condition true once it reaches 10, = will not work because you are looping only while counter is = 10 (which it doesnt so will exit)
So the first time you loop - your counter will = 1 as you have incremented it so the condition is false and breaks the loop.
Hope thats helps
yes it does. Thank you.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.