BreakCondition on "For Each" element

By Johan den Ouden on 17 May

When you use a "For each" element it would by very nice to set a breakcondition.

Imagine I have 1000 records and need to find a specific record.

In the loop it would be verhy handy to set a variable IsFound to true and check this  on the next interation ofthe loop.

If the records was found on iteration 2 there is no need to iterate the other 998 iterations.

 StopLoop.JPG

What you are describing is a conditional breakpoint which has been on the idea list for a long time.  Here's the link -
https://www.outsystems.com/ideas/66/conditional-breakpoint - please like that one.

Oke thanks!

Hi Curt,

I don't think that Johan is talking about that.

He means that we should be able to set a condition in ForEach node that will not keep iterating when that condition match.

The other idea is for debugging purposes. This one is not. This one is for runtime itself.

Am I right?


Cheers.

Nuno,

You are absolulty right!
Thanks for your comment and I hope it will be picked up by OutSystems.

J.18 May

there is a similar idea, regarding whiles I believe.


tbh, I don't like the fact you should break out of a for-each loop, because then for-each is not correct naming.

I prefer a new "node" while. :P


Why not both?


In c# you can also break a in a for each loop.

J.22 May

Hmm,

For some reason I was under the impression, you want to breakout inside the for-each-loop whereever you could.

But if you mean like this:

Yes that is want I meant

The check must be done everytime your on the for eacht widget again

This can actually be achieved by putting the loop inside a separate action, and when your condition is met, you just point to an end node. That way you jump out of the action, and the loop is aborted.

Not usable in all conditions, but it could do the job in specific circumstances.