mIRC Home    About    Download    Register    News    Help

Print Thread
Token problem #241121 20/03/13 02:50 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I dont know if token is the best way to do this? If i type

/join #one,#two,#three

and i want a delay between the join of the channels, but i cant figure out the best way to do this, since you use "," between the channel names any of $gettok() , $matchtok() , $findtok() will return a error. So how would i do this the best way?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: Token problem [Re: sparta] #241122 20/03/13 02:59 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You can use $gettok() but you need to set #one,#two,#three to a variable first.

$gettok(#one,#two,#three,1,44) - this won't work.
var %chans = #one,#two,#three | echo -a $gettok(%chans,1,44) - this will work.

Let me know if you need help with the rest of the script now that you know how to get the token identifiers working.

Re: Token problem [Re: hixxy] #241210 27/03/13 05:54 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
try using this alias

Code:
alias join {
  if (!$1-) { echo 4 -a ERROR: Not enough parameters, try again and enter the channel(s) you want to join! - (/join) | return }
  var %chans = $1-
  var %i = 1
  while (%i <= $numtok(%chans,44)) {
    var %c = $gettok(%chans,%i,44)
    .timer[JOIN_ $+ %c $+ _DELAY] 1 %i join %c
    inc %i
  }
}

Re: Token problem [Re: westor] #241220 28/03/13 11:10 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Just one small comment: rather than call $numtok() repeatedly, you should set the value to a variable:

Code:
var %i = 1, %count = $numtok(%chans,44)
while (%i !> %count) {
  ...
}

Re: Token problem [Re: hixxy] #241225 30/03/13 02:12 AM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
what's the difference ?

Re: Token problem [Re: westor] #241238 30/03/13 07:13 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Performance. Granted, for the number of loops you're talking about, it's such a minimal performance increase that it really doesn't matter. I think the main reason for the suggestion is to get in the habit of using the best performing code every time, even if the difference is negligible.


Invision Support
#Invision on irc.irchighway.net
Re: Token problem [Re: Riamus2] #241249 31/03/13 04:32 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Exactly that. In this case there's not going to be a big performance overhead, but if you were calling something like $com() in a loop rather than setting the result to a variable it would cause a massive delay.