return early from a for loop?

Get help using Construct 2

Post » Mon Jul 29, 2013 9:03 pm

I have a function to test all objects, and finding one fail, should return immediately.

Currently I have it like this:

function On "checkAll" : set return value to "TRUE"
--for each ob : call "testMyObject" (ob.myValue)
----function.ReturnValue = 0 : set return value to "FALSE"
                             : return!!!!!!

function On "testMyObject" : do really complicated stuff.

Where I have written return!!!! I just want to end the for loop, as I want to immediately return FALSE as if the test on one failed, the whole test failed. Currently it still loops through the remaining objects, taking a lot of time.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Mon Jul 29, 2013 9:09 pm

there is an action "stop loop" not sure if it works for "for each"

add action > under general
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Mon Jul 29, 2013 9:42 pm

ha, it works! nice one.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942


Return to How do I....?

Who is online

Users browsing this forum: Anonnymitet, jorgmaquoi, maxwell88, TELLES0808 and 4 guests