cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Xiarno
New Member

Loop throws index out of range.

So I'm trying to have the name of all folder in a folder, then remove the file path of the name so I can get the name alone. It gives me an index error, but it still works great so it doesn't really matter there. The thing is, this was one part of a bigger flow. And when this error get thrown, it stops the rest of the flow, which is a problem there.

Xiarno_0-1644360872980.png

Xiarno_1-1644360883209.png

How to fix this if possible please ?

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelAnnis
Super User
Super User

Loop 0 to %Folders.Count - 1%

 

Since the list has a 0 based index, there is 1 less index than number of rows.  Count returns the number of rows, so you have to subtract 1 to loop on indexes.

View solution in original post

2 REPLIES 2
MichaelAnnis
Super User
Super User

Loop 0 to %Folders.Count - 1%

 

Since the list has a 0 based index, there is 1 less index than number of rows.  Count returns the number of rows, so you have to subtract 1 to loop on indexes.

itomti
Advocate I
Advocate I

Dunno, to me it seems like loops should be < not <= when doing the Count or Length comparison.

 

Seems strange that this stayed the same since WinAutomation transition.

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Top Solution Authors
Top Kudoed Authors
Users online (3,382)