Legacy GM deeply nested break; flow control question

csanyk

Member
Question on break. If you're in a nested flow structure, how does break work?

I have the following situation:

Code:
Event:
     if condition
     {
          with(instance)
          {
               while loop
               {
                    if condition
                    {break;}
                }
          }
     }
}
Does break exit the if? The while? The with? the outer if? The Event?

For what it's worth, i'd like to exit the While loop if the innermost if condition is true.

Is it consistent between GMS1 and GMS2? Between different target platforms?
 

FrostyCat

Member
break only pops out of its most immediate parent loop, with or switch block, and has no effect on if blocks. In your example, the break statement exits the while loop. This is consistent on all exports, and in its most basic form, on arguably all languages that descend from C structure.
 

csanyk

Member
break only pops out of its most immediate parent loop, with or switch block, and has no effect on if blocks. In your example, the break statement exits the while loop. This is consistent on all exports, and in its most basic form, on arguably all languages that descend from C structure.
Thanks, @FrostyCat. I *thought* that was the case, but I wasn't completely sure, and the manual wasn't as detailed as I was hoping.
 
Top