ID:172334
 
I need some refreshing on my coding of loops. If, for example, you have this:
var/e=1
while(e<10)
for(var/mob/M in world)
M.RandomVar = E
E++


Will the whole thing stop the second E>=10, or, will the "for" continue until all the mobs have been checked, and THEN the "while" will be checked? Also, I read the Break help text, and it said you are meant to do "Break Label" with Label as whatever you labelled the loop. But how do you label a loop? And if you have something like this :

var/e=1
while(e<10)
for(var/mob/M in world)
M.RandomVar = E
if(E==5)
break
E++


Does the break stop the For and the While, or just the For? Now I know I could have done tests to find out MOST (but not all) of this information, but I thought that by asking on here, not only would I get the answers, but also the amazing opinions of the expert gurus on here too.

Thank you for your time!

[Edit]I knew that Garthor, I just missed it out :P Thanks![/Edit]

~Ease~
Ease wrote:
I need some refreshing on my coding of loops. If, for example, you have this:
> var/e=1
> while(e<10)
> for(var/mob/M in world)
> M.RandomVar = E
> E++
> <dm>
>
> Will the whole thing stop the second E>=10, or, will the "for" continue until all the mobs have been checked, and THEN the "while" will be checked?

It will check if while is true, then run though all the mobs, then check if it is true, run through all the mobs, ect.

Also, I read the Break help text, and it said you are meant to do "Break Label" with Label as whatever you labelled the loop. But how do you label a loop? And if you have something like this :

I've never heard of labeling a break...

>
> <dm>
> var/e=1
> while(e<10)
> for(var/mob/M in world)
> M.RandomVar = E
> if(E==5)
> break
> E++
> <dm>
>
> Does the break stop the For and the While, or just the For?

I'm fairly certain it would stop the for(). if you want the while to stop, you could make it not equal true.


Hope I helped =D
I use alot of loops..
In response to DarkCampainger
Labelling a break =P I meant, how do you label a loop?Thanks for all of your help so far! Thank you!

~Ease~
<DM> goes at the start, </DM> goes at the end.