mIRC Home    About    Download    Register    News    Help

Print Thread
while loop #95819 27/08/04 03:36 PM
Joined: Mar 2004
Posts: 45
D
Daedalus Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Mar 2004
Posts: 45
I'm trying to make an alias for /join.
I want to type /j #channel1 #channel2 channel3 etc
and it will join all the channels I specify.

Code:
  
j {
var %channels = $0
while (%channels >= 0) {
join %channels
dec %channels
}
}


Any ideas on how to make it work?

Re: while loop #95820 27/08/04 04:30 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Either of the following will work and which one you use depends on your personal choice.

This will make it join the first channel, first, and the last, last.

alias j {
var %i = 1
while ($numtok($1-,32) >= %i) {
join $gettok($1-,%i,32)
inc %i
}
}

This will make it join the last channel, first, and the first channel, last.

alias j {
var %i = $numtok($1-,32)
while (%i) {
join $gettok($1-,%i,32)
dec %i
}
}

Hope this helps.

Eamonn.

Re: while loop #95821 27/08/04 04:32 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
/join #channel1,#channel2,#channel3

no need for a while loop...

but since you want an alias
j { var %i = 1 | while ($gettok($1-,%i,32)) { join $v1 | inc %i } }

Re: while loop #95822 27/08/04 05:25 PM
Joined: May 2004
Posts: 24
K
kocam Offline
Ameglian cow
Offline
Ameglian cow
K
Joined: May 2004
Posts: 24
alias j join $*

Re: while loop #95823 27/08/04 05:40 PM
Joined: Mar 2004
Posts: 45
D
Daedalus Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Mar 2004
Posts: 45
One more thing...I want it to automaticlly put # in front of the channel names...

Re: while loop #95824 27/08/04 06:10 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788

join $gettok($1-,%i,32)

becomes,

join $+(#,$gettok($1-,%i,32))


Eamonn.

Re: while loop #95825 27/08/04 07:33 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Try this (put it in the Remotes section):
Code:
on *:start:unset %maxtargets.*
raw 005:* MAXTARGETS=*:set %maxtargets. $+ $cid $int($gettok($matchtok($1-,MAXTARGETS=*,1,32),2,61))
alias j {
  var %i = 1, %maxt = $iif($eval($+(%,maxtargets.,$cid),2),$v1,1), %j, %chans
  while %i <= $0 {
    %j = 1
    %chans = $null
    while (%j <= %maxt) && (%i <= $0) {
      %chans = $addtok(%chans, $eval($+(#$$,%i),2), 44)
      inc %i
      inc %j
    }
    join %chans
  }
}


It's untested but I think it should work.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: while loop #95826 28/08/04 06:53 AM
Joined: Aug 2003
Posts: 314
S
Sigh Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
$matchtok doesn't support wildcards so just leave off the * or use $wildtok, same thing

Re: while loop #95827 28/08/04 12:13 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Ahh yes, in that case it should use $wildtok, just in case there's a token like MADMAXTARGETS=MelGibson that could throw off $matchtok.


Spelling mistakes, grammatical errors, and stupid comments are intentional.