# Iterator break/continue

**URL:** https://www.finalbuilder.com/forums/t/iterator-break-continue/311
**Category:** Discussion
**Created:** [January 16, 2007, 7:22am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311 "2007-01-16T07:22:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jhunsaker](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jhunsaker](https://www.finalbuilder.com/forums/u/jhunsaker)
#### Post date: [January 16, 2007, 7:22am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/1 "2007-01-16T07:22:15Z")

</div>

Forgive me if I’m just not seeing it but is there a way to break out of an iterator (File, specificly)? This would be analgous to continue or break in C#.   
  
Thanks.

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [January 16, 2007, 11:16am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/2 "2007-01-16T11:16:15Z")

</div>

Jeff,  
  
Sorry, there’s no way to break out of an iterator at the moment… I’ve put it on the todo list to add this kind of functionality.  
  
(although, there is a dodgy way to achieve a break by calling Action.Reset in the OnAfterEachIteration script event. This causes the action to fail though, instead of breaking elegantly).  
  
.t8

---

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [January 17, 2007, 2:25am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/3 "2007-01-17T02:25:23Z")

</div>

A slightly more elegant way is to throw an exception, and wrap the iterator in a try/catch block. If you do that, make sure to set some variable just before you throw the exception, and test for it in the catch block, otherwise you might miss “real” exceptions.  
  
Steve

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 19, 2010, 12:08pm UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/4 "2010-08-19T12:08:17Z")

</div>

Is this still at the top of the TODO list? I’d also like a better way to break out of an iterator. Try/catch doesn’t seem like the most intuitive way to do this.   
  
 Thanks,   
  
 Nick

---

<div class="post-metadata">

### Author: ![jim\_shawver](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jim\_shawver](https://www.finalbuilder.com/forums/u/jim_shawver)
#### Post date: [June 19, 2015, 11:50am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/5 "2015-06-19T11:50:41Z")

</div>

Please add me to the wish list for this. I am currently using the try-catch method as suggested, but a more elegant way to break out of an iterator would be useful for my current project.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [June 20, 2015, 3:23am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/6 "2015-06-20T03:23:22Z")

</div>

There is an Exit Loop action in the current version of FinalBuilder. Not quite sure when it was added but was a while back.

---

<div class="post-metadata">

### Author: ![jim\_shawver](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jim\_shawver](https://www.finalbuilder.com/forums/u/jim_shawver)
#### Post date: [June 22, 2015, 3:27am UTC](https://www.finalbuilder.com/forums/t/iterator-break-continue/311/7 "2015-06-22T03:27:37Z")

</div>

Thanks Vincent, I didn’t see that before. It works as expected.
