mIRC Home    About    Download    Register    News    Help

Print Thread
Token help needed. #204973 08/10/08 08:10 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
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.
Re: Token help needed. [Re: ots654685] #204974 08/10/08 08:27 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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
}


Re: Token help needed. [Re: RusselB] #204975 08/10/08 08:33 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
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

Re: Token help needed. [Re: ots654685] #204976 08/10/08 10:17 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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).

Re: Token help needed. [Re: RusselB] #204982 08/10/08 04:52 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
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

Re: Token help needed. [Re: ots654685] #205010 09/10/08 07:36 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
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.
Re: Token help needed. [Re: ots654685] #205011 09/10/08 07:56 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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).

Re: Token help needed. [Re: RusselB] #205510 24/10/08 05:39 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
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

Re: Token help needed. [Re: ots654685] #205511 24/10/08 06:04 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline
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)

Re: Token help needed. [Re: OrionsBelt] #205513 24/10/08 08:32 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.

Re: Token help needed. [Re: ots654685] #205634 27/10/08 12:53 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
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.