mIRC Home    About    Download    Register    News    Help

Print Thread
/hop -a #145752 27/03/06 03:58 PM
Joined: Nov 2004
Posts: 802
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Nov 2004
Posts: 802
(Yes I did search ...)

Not really much of an idea, but something like /hop -a which makes you hop all channels you are currently on on the current network.

Thats all.


What do you do at the end of the world? Are you busy? Will you save us?
Re: /hop -a #145753 27/03/06 04:08 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
floods you off =)


IceCapped
Re: /hop -a #145754 27/03/06 05:39 PM
Joined: Feb 2006
Posts: 164
V
vexed Offline
Vogon poet
Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
Code:
 hopall { 
  var %x = $chan(0) 
  while (%x) { 
    hop -c $chan(%x) 
    dec %x 
  } 
} 

Re: /hop -a #145755 28/03/06 12:05 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
That flooded me off of the network I tried it on, however, the following (which is close) did not
Code:
alias hopall {
var %a = 1
while %a <= $chan(0) {
.timer 1 %a hop -c $chan(%a)
inc %a
}
}
  

Re: /hop -a #145756 29/03/06 03:38 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
so do you mean to part all the channels you are in and hop to one other channel?

Code:
alias hopto {
  var %chanlist = $?="Input channels to hop to like #chan1,#chan2,#chan3)"
  partall
  join %chanlist
}

let me leave all I was in and join 3 others i put in the input box

Re: /hop -a #145757 29/03/06 06:44 AM
Joined: Jan 2006
Posts: 468
symphony Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2006
Posts: 468
This will lag you, joining a number of channels all at once,
use /mjoin with a timer.

Re: /hop -a #145758 29/03/06 07:38 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
/mjoin? I'm unable to find this command in the mIRC help file.

Re: /hop -a #145759 29/03/06 09:21 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I just guessing, but mjoin is prolly a part of a script he using, the command dosent work in my client atlest. So i wouldent think you will find it in any mirc's *.hlp files or any other default file that comes with mirc. wink


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: /hop -a #145760 29/03/06 08:36 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:
This will lag you, joining a number of channels all at once,
use /mjoin with a timer.


putting aside the nonexistent command, you would have to join a lot of channels to lag, and once they were all joined you shouldnt be lagging anymore.

how many channels do you join at one time? (per network)

Re: /hop -a #145761 29/03/06 08:48 PM
Joined: Nov 2004
Posts: 802
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Nov 2004
Posts: 802
Code:
/hopall {
  if ($status == connected) {
    var %x = 0
    while (%x < $chan(0)) {
      inc %x 1
      if (%x == 1) {
        var %chanlist = $chan(%x)
      }
      else { var %chanlist = %chanlist $+ , $+ $chan(%x) }
    }
    part %chanlist $1-
    join %chanlist
  }
}


Guess that'll have to be my workaround for the time being ...

I suppose I'll throw this out on a limb as well

/hop #chan1,#chan2,... support?

Last edited by Jigsy; 29/03/06 08:52 PM.

What do you do at the end of the world? Are you busy? Will you save us?
Re: /hop -a #145762 29/03/06 09:32 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Code:
/hopall {
  if ($status == connected) {
    var %x = 0
[color:blue] I have seen it often enough that you shouldnt use identifiers in while loops, so i made this change[/color]
var %chans = $chan(0)
    while (%x < %chans) {
      inc %x 1
      if (%x == 1) {
        var %chanlist = $chan(%x)
      }
      else { var %chanlist = %chanlist $+ , $+ $chan(%x) }
    }
[color:blue]not that it reallymatters but partall is handy[/color] 
    partall $1-
    join %chanlist
  }
}


I had done it like this
Code:
alias hopall {
  if ($status == connected) {
    var %chanC = $chan(0)
    var %i = 1
    while (%i <= %chanC) { 
      var %chans = $+(%chans,$chr(44),$chan(%i))
      inc %i
    }
    partall $1-
    join %chans
  }
}


and though it adds a needless "," to the front of the var it didn't cause a problem rejoining channels

Re: /hop -a #145763 29/03/06 09:57 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Quote:
I have seen it often enough that you shouldnt use identifiers in while loops, so i made this change
var %chans = $chan(0)
while (%x < %chans) {


only reason not to use identifiers whose values dont change in the while loop is to make it faster, by ensuring the same identifier isnt needlessly re-evaluated every iteration.. though we all know the little bit of speed difference in this case is hardly noticable laugh however, it is shorter, and even 'faster' to loop like so:

while ($chan(%x)) {

then use $v1 in place of $chan(%x) in the rest of the loop


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: /hop -a #145764 29/03/06 11:07 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
while ($chan(%x)) {

this is an infinite loop as $chan(0) (the decreased value of $chan(x) is zero) you end up with all your channels in the var and then iinfinite $chan(0) appended to the end until the "* /set: line too long " error stops the loop.

Re: /hop -a #145765 29/03/06 11:48 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
It's obvious, that you'd be doing an incremental loop (start with %x = 1), if you do while ($chan(%x)) which will end when $chan(%x) is $null, meaning %x's value is one unit higher than the total amount of channels.

The only thing that matters is that you minimize the number of times the identifier is called. Like you rightfully pointed out, it's better to put the value of $chan(0) into a variable, and reference that, instead of each time making mIRC retrieve the number of channels you're on.

Aside from that, whether you loop like:

var %x = 1
while ($gettok($1-,%x,32) != $null) {
; do something with $v1
inc %x
}

or

var %x = 1, %y = $0
while (%x <= y) {
; do something with $gettok($1-,%x,32)
inc %x
}

Doesn't really make any difference. Although $gettok is referenced once more in the one where it is in the while condition, on the other hand, it doesn't have to assign $0 to a variable like in the second example. Which one you choose will certainly not be based on efficiency/speed issues, as they are of no importance here.

Cases where you'll want to be against the putting of the identifier in a while condition is those that could be avoided, and should be avoided because of the inefficiency they represent. Examples of these are: $len() or $lines(). Instead of doing something like while (%x <= $lines(file.txt)) it is advised to put the value of $lines() into a var and compare %x to this. For $lines() to work, it must open the file (this means disc access) and check how many lines there are. This is far more intensive than checking the value of a variable.

Thus here, calling $lines more than once is unjustified, and should be avoided. In the case of the $gettok, or in this thread $chan(%x) you are going to need to retrieve the value of that identifier with each iteration anyway, so whether you put it in the while condition or reference it inside the body really doesn't matter.


Gone.