mIRC Homepage

* Invalid format: $instok

Posted By: sparta

* Invalid format: $instok - 09/10/07 06:28 AM

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
  }
}
Posted By: RusselB

Re: * Invalid format: $instok - 09/10/07 07:08 AM

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)

Posted By: sparta

Re: * Invalid format: $instok - 09/10/07 07:41 AM

Still same problem:

* Invalid format: $instok

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

Re: * Invalid format: $instok - 09/10/07 09:06 AM

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)
Posted By: sparta

Re: * Invalid format: $instok - 09/10/07 09:36 AM

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
  }
}
Posted By: Riamus2

Re: * Invalid format: $instok - 09/10/07 10:13 AM

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.
© 2019 mIRC Discussion Forums