mIRC Home    About    Download    Register    News    Help

Print Thread
#49945 18/09/03 03:22 AM
Joined: Jul 2003
Posts: 39
X
Xanadu Offline OP
Ameglian cow
OP Offline
Ameglian cow
X
Joined: Jul 2003
Posts: 39
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

Last edited by Xanadu; 18/09/03 03:23 AM.
#49946 18/09/03 08:19 AM
Joined: Jan 2003
Posts: 9
P
psy Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
P
Joined: Jan 2003
Posts: 9
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.

Last edited by psy; 18/09/03 08:19 AM.
#49947 18/09/03 09:56 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
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


new username: tidy_trax

Link Copied to Clipboard