mIRC Home    About    Download    Register    News    Help

Print Thread
#193616 22/01/08 06:01 PM
X
XTZGZoReX
XTZGZoReX
X
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.

5
5618
5618
5
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
W
Hoopy frood
Offline
Hoopy frood
W
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
X
XTZGZoReX
XTZGZoReX
X
Yes, but is it possible to like, name the loop, and /break <name> it, or something similar?

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
The simplest solution is to put a :label where you want to /break to and use /goto label.

X
XTZGZoReX
XTZGZoReX
X
So like,

Code:
: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
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Multiple methods...

Code:
  while (%i < %x) {
    if (something) { break }
    inc %i
  }


Code:
  while (%i < %x) {
    if (something) { return }
    inc %i
  }


Code:
  while (%i < %x) {
    if (something) { goto end }
    inc %i
  }
  :end

X
XTZGZoReX
XTZGZoReX
X
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
G
Hoopy frood
Offline
Hoopy frood
G
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
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 1,997

Not even changing conditions locally can break the loop, only from within the script itself I guess.

Code:

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...


Code:

alias looptest {
  var -s %ticks = $calc($ticks + 5000)
  while ($ticks < %ticks) noop
  echo -a STOPPED
}




Link Copied to Clipboard