The "Continue" Statement

This section covers the "continue" statement.

The continue statement has the form:


If used inside of a statement that forms a loop (repeat, while, do... until or for), it will immediately jump back to the beginning of the loop as if the loop had run through and looped back (if used outside of a loop it acts as an exit statement, exiting the event). It will also do the same when using the with function, where it will cause the code to skip to the next instance and run again.

Below is an example of its use in a "for" loop:

var i;
for (i = 0; i < 10; i += 1)
   if array[i] = "" continue;
   array[i] = "";

The above code will skip back to the beginning of the loop if the array[i] value is already an empty string.

Back: GML Overview
Next: The "Exit" Statement
© Copyright YoYo Games Ltd. 2018 All Rights Reserved