Blockland Forums > Modification Help
What is the point of continue; ?
Nexus:
I see this:
--- Code: ---continue;
--- End code ---
often, especially in functions dealing with other files. I do not understand why you need to tell the script to continue, since it will always do so unless you tell it specifically to stop.
Can someone explain this to me?
example from the advanced wrench GUI
--- Code: ---
if(getsubstr(%line,0,1) $= "#")
{
continue;
}
--- End code ---
Destiny/Zack0Wack0:
It tells the game to immediately continue to the next iteration in while and for loops.
Nexus:
--- Quote from: Destiny/Zack0Wack0 on February 19, 2011, 12:27:31 AM ---It tells the game to immediately continue to the next iteration in while and for loops.
--- End quote ---
Would it not do that if there was no continue; there?
M:
--- Quote from: Nexus on February 19, 2011, 03:26:25 AM ---Would it not do that if there was no continue; there?
--- End quote ---
You can have code after the continue that will be ignored if whatever triggers that continue is true, if you need to do that. I've used it in a bunch of places but can't think of a good example right now though.
Space Guy:
--- Code: ---for(%i=0;%i<10;%i+=1)
{
if(%i == 5)
continue;
echo(%i);
}
--- End code ---
--- Quote ---1
2
3
4
6
7
8
9
--- End quote ---