mIRC Homepage
Posted By: ots654685 Token help needed. - 08/10/08 08:10 AM
Having problems correctly implement the use of tokens.

Did read help file and it looked simple but as i search the forum or web i see so many exotic token strings which makes my head roll.

i started very simple:
on *:TEXT:*:#: {
var %line $strip($1-,burc)
var %text = $gettok(%line,5,32)
/echo -a %text

But in some cases i have some text in the grabbed text that i don't need, example blabla/The.text.needed

Before the use of tokens i just used something like this
$right($strip($8),-5) but first checked if there was \ in line and then started striping

How do i use that using tokens?
Posted By: RusselB Re: Token help needed. - 08/10/08 08:27 AM
In this case, $gettok(%line,5,32) is returning the set of characters between the 4th and 5th space characters.
If you know that the character you don't want is the / character, then you could do a 2nd $gettok to handle that character.

Here's your code with that change.

on *:text:*:#:{
  var %line = $strip($1-,burc)
  var %text = $gettok(%line,5,32)
  var %text = $gettok(%text,-1,47)
  echo -a %text

and here is another re-write using some more token functions.. it's a bit more advanced than what you have.
on *:text:*:#:{
  tokenize 32 $strip($1-)
  var %text = $gettok($5,-1,47)
  echo -a %text

Posted By: ots654685 Re: Token help needed. - 08/10/08 08:33 AM

The trick (at least for me) is to do a gettok again but i prefer the more advanced way of handling it but information about that can't be found in standard mirc help file
Posted By: RusselB Re: Token help needed. - 08/10/08 10:17 AM
It's all in the standard mIRC help file.
/help /tokenize
/help $strip
/help $gettok

If this information isn't in your help file, make sure that you have the latest version (6.34), although, if I recall correctly, this information hasn't changed since 6.17 (or possibly earlier).
Posted By: ots654685 Re: Token help needed. - 08/10/08 04:52 PM
I forgot to add / in front wink

Is it possible to make $5 in var %text = $gettok($5,-1,47)
a var as in %pos ?

var %text = $gettok(%pos,-1,47)

I tried that but didn't worked out the way i expected
Posted By: ots654685 Re: Token help needed. - 09/10/08 07:36 AM
Something like this?

on *:TEXT:*:#:{
if ($chan >= #channel) { var %pos = $4 }
if ($chan >= #next) { var %pos = $8 }
else { var %pos = $5 }
tokenize 32 $strip($1-)
var %text = $gettok(%pos,-1,47)

$chan >= #channel is there because i have channels named like
#channel-org etc
Posted By: RusselB Re: Token help needed. - 09/10/08 07:56 AM
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if $chan == #channel {    var %text = $4  }
  elseif $chan == #next {    var %text = $8  }
  else {    var %text = $5  }
  %text = $gettok(5text,-1,47)
  echo -a %text

When comparing the name of a channel to $chan, you can only use ==
There is no way for mIRC to know if #channelA is greater or lesser than #channelB, but it can tell if #channelA matches #channelB (using a text match comparison).
Posted By: ots654685 Re: Token help needed. - 24/10/08 05:39 PM
I managed to get earlier problem fixed but how about detecting if there is an / in it or not instead of stripping it out?

I was thinking about $istok function but the help file only guided me for normal text strings and not special characters.

//echo -a $istok(some/text/with/many/in/it,/,32)

Only returned $false

changing 32 in to 47 didn't helped me either
Posted By: OrionsBelt Re: Token help needed. - 24/10/08 06:04 PM
Below are some examples.
Don't have mIRC right here now, but I think this should be correct.

From Help:

var %line = some/text/with/many/in/it
echo -a $istok(%line,$chr(47),32)

var %line = some / text / with / many / in / it
echo -a $istok(%line,$chr(47),32)

var %line = some/text/with/many/in/it
echo -a $iif(($chr(47) isin %line),True,False)
Posted By: Tomao Re: Token help needed. - 24/10/08 08:32 PM
on *:TEXT:*:#: {
  if ($regex($1-,(\057))) { echo -a True }
  else { echo -a False }

This will match / in a line.
Posted By: DJ_Sol Re: Token help needed. - 27/10/08 12:53 PM
Ok I know this isn't a "Token Identifier" answer, but have you checked out $nopath and $nofile? These might help do what you want to do.
© mIRC Discussion Forums