|
|
XTZGZoReX
|
XTZGZoReX
|
Is there a way that I can break out of a specific while loop, or will only /break do that? If so, can you even have more than one loop at the same time?
Thanks.
|
|
|
|
5618
|
5618
|
Well, you can break out of a loop with 'break' or by making your while-statement false. And it's possible to use a while loop inside another, yes.
|
|
|
|
Joined: Jul 2006
Posts: 4,020
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,020 |
/return, /halt, /goto can break a while loop but should be used carefuly
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
XTZGZoReX
|
XTZGZoReX
|
Yes, but is it possible to like, name the loop, and /break <name> it, or something similar?
|
|
|
|
Joined: Jan 2003
Posts: 2,125
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,125 |
The simplest solution is to put a :label where you want to /break to and use /goto label.
|
|
|
|
XTZGZoReX
|
XTZGZoReX
|
So like,
:somelabel
while ( stuffs here ) {
commands here
}
But I don't get how I can make break stop that exact part? Basically, I want to start a while loop that I can suddenly pop up out of nothing, and end.
Last edited by XTZGZoReX; 25/01/08 04:58 PM.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Multiple methods...
while (%i < %x) {
if (something) { break }
inc %i
}
while (%i < %x) {
if (something) { return }
inc %i
}
while (%i < %x) {
if (something) { goto end }
inc %i
}
:end
|
|
|
|
XTZGZoReX
|
XTZGZoReX
|
Yes.. but I mean, start a while loop on, for example, !start, and then later on, type !stop to end that loop. Is that possible?
|
|
|
|
Joined: Oct 2005
Posts: 1,671
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,671 |
If you start a while loop and don't stop it, mIRC will lock up and not respond to any other commands. mIRC cannot process more than one script at a time, so you cannot stop one executing script by sending a command from another.
-genius_at_work
|
|
|
|
Joined: Dec 2002
Posts: 1,997
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,997 |
Not even changing conditions locally can break the loop, only from within the script itself I guess.
alias looptest {
timerLoopTest 1 5 set -s %looptest $true
while (!%looptest) noop
echo -a STOPPED
unset -s %looptest
}
~ Edit ~ I should have said "attempting to change conditions" because as you will see when that script is executed, the timer isn't halted and variable isn't set until after you hit ctrl+break.
~ Edit ~ Although changing internal identifiers can break the loop...
alias looptest {
var -s %ticks = $calc($ticks + 5000)
while ($ticks < %ticks) noop
echo -a STOPPED
}
|
|
|
|
|
|