Loop something x number of times


#1

Hi UiPath.

I have made a workflow, which reads a number from a piece of text via screen scraping. I want the proces/workflow to do the action as many times as the number from the screenscraping. Lets say the number says 500. Have do i make it loop 500 times?

Regards Kenni


#2

Hi @Kekth,

declare the intstartNumber=1
use while loop activity to loop through it. (totalcount>=intstartNumber)
at the end of the loop increment +1

Regards,
Arivu


#3

You can create and increment a counter, like @arivu96 suggested.

Another option is to use a For each activity with Enumerable.Range(0,500).ToArray():


#4

The intstartNumber is that a variable I should create, and set default value to 1?
And where do I create/insert " (totalcount>=intstartNumber)" ?? and also input the “increment +1”?

I have the number from the screenscraping typed into the notepad(just to get an output from the datatable). Can it read that number somehow an insert it/use it in what you just suggested?


#5

Hi @Kekth,

yes you are right

totalcount is how many times you want loop count.

inside the while condition need to increment value to achieve the total value.

Regards,
Arivu


#6

Hi @Arivazhagan

I have now created the variable and set the value to 1.

Should I put this in an assign:?

And also this in an assign: ?

And then put it inside the body in the loop?


#7

Hi @Kekth,

(totalcount>=intstartNumber) ->in while condition you need to give

“intcrement +1” ->inside while body end you need to give.

“totalcount” -> how many time you want loop that count

Regards,
Arivu