mIRC Home    About    Download    Register    News    Help

Topic Options
#95819 - 27/08/04 04:36 PM while loop
Daedalus Offline
Ameglian cow

Registered: 16/03/04
Posts: 45
Loc: Finland
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?

Top
#95820 - 27/08/04 05:30 PM Re: while loop
Coolkill Offline
Hoopy frood

Registered: 09/12/02
Posts: 788
Loc: Wales, United Kingdom.
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.

Top
#95821 - 27/08/04 05:32 PM Re: while loop
Kelder Offline
Hoopy frood

Registered: 12/04/03
Posts: 701
Loc: Leuven, Belgium
/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 } }

Top
#95822 - 27/08/04 06:25 PM Re: while loop
kocam Offline
Ameglian cow

Registered: 06/05/04
Posts: 24
alias j join $*

Top
#95823 - 27/08/04 06:40 PM Re: while loop
Daedalus Offline
Ameglian cow

Registered: 16/03/04
Posts: 45
Loc: Finland
One more thing...I want it to automaticlly put # in front of the channel names...

Top
#95824 - 27/08/04 07:10 PM Re: while loop
Coolkill Offline
Hoopy frood

Registered: 09/12/02
Posts: 788
Loc: Wales, United Kingdom.

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

becomes,

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


Eamonn.

Top
#95825 - 27/08/04 08:33 PM Re: while loop
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#95826 - 28/08/04 07:53 AM Re: while loop
Sigh Offline
Fjord artisan

Registered: 28/08/03
Posts: 314
$matchtok doesn't support wildcards so just leave off the * or use $wildtok, same thing

Top
#95827 - 28/08/04 01:13 PM Re: while loop
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top