mIRC Home    About    Download    Register    News    Help

Print Thread
#204973 08/10/08 08:10 AM
Joined: Feb 2006
Posts: 97
O
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
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?

Last edited by ots654685; 08/10/08 08:11 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Code:
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.
Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  var %text = $gettok($5,-1,47)
  echo -a %text
}


Joined: Feb 2006
Posts: 97
O
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
Thanks,

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

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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).

Joined: Feb 2006
Posts: 97
O
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
@RusselB
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

Joined: Feb 2006
Posts: 97
O
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
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)
}

note:
$chan >= #channel is there because i have channels named like
#channel-new
#channel-fun
#channel-org etc

Last edited by ots654685; 09/10/08 07:47 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
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).

Joined: Feb 2006
Posts: 97
O
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
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

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Below are some examples.
Don't have mIRC right here now, but I think this should be correct.

From Help:
$istok(text,token,C)

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

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

True:
var %line = some/text/with/many/in/it
echo -a $iif(($chr(47) isin %line),True,False)

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
on *:TEXT:*:#: {
  if ($regex($1-,(\057))) { echo -a True }
  else { echo -a False }
}


This will match / in a line.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.


Link Copied to Clipboard