mIRC Home    About    Download    Register    News    Help

Print Thread
#152979 09/07/06 08:47 AM
Joined: Jul 2006
Posts: 3
V
vader Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Jul 2006
Posts: 3
i have been scripting for a few weeks and i have seen things like
tokenize 32 %blah....and i dont know what it does....what does 32 stand for? and does tokenize just turn the number 32 into a token?

also a friend was having problems with this code:
set %a $right($gettok($mid($2,$pos($2,'t=),$len($2)),1,38),-3)
set %b $right($gettok($gettok($mid($2,$pos($2,'t=),$len($2)),2,38),1,39),-2)
in the first line of code you have the identifier $gettok only once....but in the second line you have it twice, why?

#152980 09/07/06 09:24 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
First query: The tokenize command will separate the information based upon the character supplied. The 32 (in your example) is the ascii value of the character used to separate the different tokens (in this case, the space character)

/help /tokenize makes it about as clear as possible, and includes an example.

Regarding your second query, the two lines return completely different characters, and use different characters to determine the tokens.

Each line could be re-written in simpler (yet longer) forms.
For the first one it could be like
Code:
 set %a $pos($2,'t=)
set %b $mid($2,%a,$len($2))
set %c $gettok(%b,1,38)
set %d $right(%c,-3)
set %a %d
 

In this one, first the term 't= is located in $2, then the position of that term is stored in %a
Next, %b is set to hold anything after that term, including the term, to the end of the entry
Then, %c is set to the characters going from the start to (but not including) the first occurance of the character represented by the ascii value of 38 (the & sign)
Next the %d is set to all of the characters from the start to the end of %c with the exception of the first 3
Finally %a is set to the same value as %d

The second one could be like
Code:
 set %a $pos($2,'t=)
set %b $mid($2,%a,$len($2))
set %c $gettok(%b,2,38)
set %d $gettok(%c,1,39)
set %e $right(%d,-2)
set %a %e
 


In this one, while it start off the same for the first two variables, the 3rd (%c) is set to the characters between the first and second & signs, then it looks for the first occurance in that section for the apostraphe ('), then returns all but the left 2 characters.

Since the second code looks for two different token indentifiers, there has to be a gettok for each.

I hope this explains your question, and, if that was where your friend was having problems, it helps resolve the problems.

I find when writing code, it's easier to put the code simply (like I did above) then when I have it working, combine the different steps into a single line.

#152981 09/07/06 08:42 PM
Joined: Jul 2006
Posts: 3
V
vader Offline OP
Self-satisified door
OP Offline
Self-satisified door
V
Joined: Jul 2006
Posts: 3
yes i see what you mean:
set %bleh $right($gettok($mid($2,$pos($2,'t=),$len($2)),1,38),-3)
set %blah $right($gettok($gettok($mid($2,$pos($2,'t=),$len($2)),2,38),1,39),-2)

now that you have explained it i see exactly what you mean....and how it could be re-written in simpler form. Your code is definitely less confusing than these lines. It just uses more vars and in the end does the same thing.
I'm sorry yea your right i didnt even think to use the /help /tokenize, but it is right there but the mirc help file is huge and im finding it hard to remember all of the commands and identifiers, i guess it just takes time to memorize all of them.

#152982 09/07/06 08:53 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The Find tab in the help system is handy when you have an idea as to what you're looking for, but not exactly sure.

Glad I was able to help clarify those lines.

#152983 11/07/06 08:39 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
the help system in mirc does not make it understandeble for all users.
here everything is explained much easyer.

Thank you all for doing so

#152984 11/07/06 10:22 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I agree that the Help file isn't always the clearest, however, it is a good location to start when trying to figure out how/why something does or does not work.


Link Copied to Clipboard