[INFO] Explanation how gettok Works...
 
Post new topic   Reply to topic    Hawkee.com Forum Index -> mIRC Tutorials
 
ProIcons  -  Thu May 12, 2011 1:41 am Reply with quote
Well a we use very often a function of a mIRC that called gettok, and it really doesn't exists to other Programming and Scripting Languages. In this topic i will explain to you how it works so if you can,want,have the skills to do it in another scripting / programming language for make easier your life i guess...

Before we begin, please be advised that this tutorial is intended for intermediate level scripters. It will not cover any basic concepts and assumes that you know the syntax of mIRC Scripting.


Well let's start. First of all we will need some loops, and the functions "mid" and "len"

Code
 

First of all we need to make some local variables to our function to work with. the %i will work for the loop that we will construct later and the %nwords will be the counter that it will inform us when we will reach the word that we ask for...
Code
 

if you noticed on the loop we are checking every single letter to check our delimeter. With this we will be able to identify on what word we will be at this time...
we can also change here the
Code
 
to
Code
 
and
Code
 
to
Code
 
it is the same thing...
Code
 

In the first "if" statement with the mid function we are checking each letter if it is our delimeter... if it is we are increasing the local counter "nwords" for the NEXT if statement.

So now in the second "IF" statement we are checking is the number of word that we are asking is counted by the local counter (nwords), we are breaking the loop there to continue the procedure... if not we are waiting for the loop to find it...
Code
 

After we find the word, or the loop does not find any result we are continuing to our second loop...
in this we are setting the variable %z to variable %i plus (+) 1 and starting the loop again to check every letter on our text... Now if the previous loop has not result the %i will be the length ($len) of our text ($1) so i will just do not return any result at all at the second loop...

Now in the second loop in the 1st "IF" statement we are checking if the character that we are checking is our delimeter. If yes we found our word! first the begin in the first loop and after that the end in the second loop...
Now i guess we want to return our result. So there is the complete function of gettok:
Code
 


I hope you understand it , it is known that my english sucks but anyway Very Happy
Display posts from previous:   
Post new topic   Reply to topic    Hawkee.com Forum Index -> mIRC Tutorials All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.