mIRC Home    About    Download    Register    News    Help

Print Thread
#232594 10/06/11 06:50 PM
Joined: Jun 2011
Posts: 6
M
mur_phy Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2011
Posts: 6
Someone could explain me the command "/tokenize"
Code:
on 1:text:*:#:{
  tokenize 32 $strip($1-)
...
}

mur_phy #232595 10/06/11 07:01 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
/tokenize <delimiter> <data>
Tokenize fills $1-[$2,$3,...] with <data> separated by the specified delimiter. The delimiter is the numeric value of a character



/Example This is "$1-"
Code:
alias Example {
  echo -a Input: $1-
  var %Output = Notice how "$1-" changed
  tokenize 32 %Output
  echo -s Output: $1-
}


I am SReject
My Stuff
mur_phy #232596 10/06/11 09:47 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
That line is commonly used to strip out all the space separated tokens from $1, $2, $3, etc..., depending on how many tokens being used. The /tokenize command works somewhat similar to $gettok()

Let's take the nickname Froggie Da Frog for instance:

As you can see there's a space delimiting the aforementioned three words. So to tokenize it, you'll do:
Code:
//tokenize 32 Froggie Da Frog | echo -a $0 $1 $2 $3
$0 equals to the total amount of tokens presented.
$1 equals to the word "Froggie"
$2 equals to the word "Da"
and $3 equals to the last word "frog"

You can use $numtok() and $gettok() to simulate the tokenization:
Code:
//var %x = Froggie Da Frong | echo -a $numtok(%x,32) $gettok(%x,1,32) $gettok(%x,2,32) $gettok(%x,3,32)
I hope this gives you a better idea, if not too thorough, about what tokenize command does.

P.S. you'll sometimes see people use
Code:
//tokenize 32 blah blah blah | echo -a $*
aka tokenize loop to have the tokens output vertically.


Link Copied to Clipboard