Add break/continue on cycles

By Filipe Silva on 10 May 2011
It is impossible to break/continue if you have more then one nested foreach cycle.
Adding an action like a terminator to a cycle could lead to the previous one, for example.
J.10 May 2011
It's not very handy to have nested loops anyways, especially if they need to be terminated.

workaround: split them into actions and bubble exceptions.

Hugo Francisco10 May 2011
The idea is to be able to break an inner cicle allowing the user to skip unwanted iterations. That would be awsome when you have several nested foreaches and you need one or more to have break conditions, reducing the number of unnecessary iterations. That would reduce the weight of an action and the time it takes to run, resulting into more optimized actions/methods.
J.10 May 2011
I am not fond of breaking out of for-loops, because for-loops are just made for looping from start to end.
While-loops are conditional-for-loops and are used just for that.

While I understand the problem, I don't think the "break" command is the solution for it. I rather have a while-do-loop and a do-while-loop.



Kilian Hekhuis22 Aug 2011
I just have a case where I could really need such a 'break'. I'm looping over a large dataset (made of structures), which contains parent/child dependencies (it's basically a tree). I want to update all childs of a particular parent, but since they're sorted, I can stop once the last one has been reached. A for each is preferable to a hand-constructed while-loop for clarity and not needing to index a record list.
Armando Gomes23 Sep 2015
+1 to this idea.
André Alho25 Jul 2016


I don't need more local vars!!!



Merged from 'Foreach Break Widget' (idea created on 2016-07-25 14:27:52 by André Alho), on 2016-08-02 10:45:02 by Goncalo Borrega
Justin James26 Jul 2016

Duplicate of: http://www.outsystems.com/ideas/776/add-break-continue-on-cycles


J.Ja



Merged from 'Foreach Break Widget' (idea created on 2016-07-25 14:27:52 by André Alho), on 2016-08-02 10:45:02 by Goncalo Borrega
Pedro Cardoso29 Jul 2016

Although I like it, there's a simple way to achieve it: refactor to an action and exit the foreach with a stop node...



Merged from 'Foreach Break Widget' (idea created on 2016-07-25 14:27:52 by André Alho), on 2016-08-02 10:45:02 by Goncalo Borrega
Niels Favreau24 Mar 2016
For example, when looping trough a list and a condition is met, we should be able to break out of the loop. (so it doesn't go further)




Merged from 'Breaking out a for each' (idea created on 2016-03-24 13:09:24 by Niels Favreau), on 2016-08-02 10:46:22 by Goncalo Borrega
Kilian Hekhuis29 Mar 2016
I'm pretty sure this Idea was posted before a couple of times.

Merged from 'Breaking out a for each' (idea created on 2016-03-24 13:09:24 by Niels Favreau), on 2016-08-02 10:46:22 by Goncalo Borrega
Daniel Cuccia1 Apr 2016
I know its not optimal - but this is how I work around the missing 'break' functionality
(basically re-inventing the "for" operator lol)




Merged from 'Breaking out a for each' (idea created on 2016-03-24 13:09:24 by Niels Favreau), on 2016-08-02 10:46:22 by Goncalo Borrega
Kilian Hekhuis1 Apr 2016
Yeah, that works of course. And if you only need to break out the entire action, you could also direct a condition to an End. But it isn't very elegant.

Merged from 'Breaking out a for each' (idea created on 2016-03-24 13:09:24 by Niels Favreau), on 2016-08-02 10:46:22 by Goncalo Borrega