mIRC Home    About    Download    Register    News    Help

Print Thread
#187624 09/10/07 06:28 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
As topic say i have problem with $istok, the problem are in this line:

%lchannel.list = $instok(%lchannel.list, $+($chan(%count1), , , 1, 33)

and i cant find out what cosing it, been testing back and forward to find out what cosing it, someone that can spot it and explain? thnx smile
Code:
alias get_channel_list {
  if ($1 isnum && $1 < 10 && $gettok(%lchannel.list, $1, 33)) {
    var %_chan =  $v1
    return . $+ $1 $+ . $gettok(%_chan,1 , 58) $+ : join %_chan
  }
  else {
    if ($1 == 1) { 
      return No channels in list: noop
    }
  }
}
alias chan_addlist {
  var %count1 = $chan(0)
  while (%count1) {
    if ($chan isin %lchannel.list) { return }
    %lchannel.list = $instok(%lchannel.list, $+($chan(%count1), , , 1, 33)
    %lchannel.list = $deltok(%lchannel.list, 9-, 33)
    dec %count1
  }
}


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
If you're trying to insert the comma character (which is what it looks like), then you have to use $chr(44) in the $instok for the character you're inserting, as that identifier uses commas to separate the various options.

Code:
%lchannel.list = $instok(%lchannel.list, $+($chan(%count1), $chr(44) , 1, 33)


Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Still same problem:

* Invalid format: $instok

so dunno, tested with your line, then tryed to edit it a bit, but no go..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
You shouldn't be using "!" as your token separator/delimiter. A channel name CAN contain "!". There's no point in adding a comma, only to use "!" as the delimiter. I'd advise you to use chr 44 and avoid that entire mess.

Doing it your way, we'd do it like this:
var %lchannel.list = $instok(%lchannel.list,$+($chan(%count1),$chr(44)),1,33)

You can clean that up by doing it like:
var %chan = $+($chan(%count1),$chr(44))
var %lchannel.list = $instok(%lchannel.list,%chan,1,33)

Making things readable is generally a good thing, especially when other people (like us) read over your code.

PS: If you were to do it the way it should be done, as in, if you used a comma, or space character as the delimiter, you wouldn't need to do the $+() stuff:
var %lchannel.list = $instok(%lchannel.list,$chan(%count1),1,44)

Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I took your advice, how ever i still have one problem, it only return the first channel in the list, the var looks like:

%lchannel.list #test,#bla,#moo

and what i get it the submenu is

1. #test

after that nothing more. How come?

; edit

But it join all channels in the %var.
Code:
alias get_channel_list {
  if ($1 isnum && $1 < 10 && $gettok(%lchannel.list, $1, $chr(44) )) {
    var %_chan =  $v1
    return . $+ $1 $+ . $gettok(%_chan,1,44) $+ : join %_chan
  }
  else {
    if ($1 == 1) { 
      return &No channels in list: noop
    }
  }
}
alias chan_addlist {
  var %count1 = $chan(0)
  while (%count1) {
    if ($chan isin %lchannel.list) { return }
    var %chan = $+($chan(%count1),$chr(44))
    %lchannel.list = $instok(%lchannel.list,$chan(%count1),1,44)
    dec %count1
  }
}

Last edited by sparta; 09/10/07 09:40 AM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Look at your code, sparta....

Code:
    return . $+ $1 $+ . $gettok(%_chan,1,44) $+ : join %_chan


Look at what you have it returning. You're using $gettok to only return the first channel. Then you're telling it to join the entire list.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard