mIRC Homepage
Posted By: Xanadu while loops - 18/09/03 03:22 AM
Can you embed a while loop inside a while loop?


EDIT: Actually, I just found that you can in the help file, can you explain the proper use of /break and /continue, though
Posted By: psy Re: while loops - 18/09/03 08:19 AM
As with most programming languages im assuming that this works the same.

Break will stop the while loop immedtiately.
Continue will stop the current loop but will go back to the top.

Eg:

while (x < 10) {
x = x + 1
print "hi"
break;
print "hello"
}

That will print "hi" once, hit the break and stop.

while (x < 10) {
x = x + 1
print "hi"
continue;
print "hello"
}

That will print "hi" 10 times, but never will display "hello" because the continue will cause it to jump back to the start of the loop.
Posted By: pheonix Re: while loops - 18/09/03 09:56 AM
alias test {
var %i 1
var %x 1
while (%i <= 10) {
%x = 1
while (%x <= 10) {
echo -a %x
inc %x
}
inc %i
}
}
type: /test
© mIRC Discussion Forums