|
| ProIcons - Thu May 12, 2011 1:41 am |
|
|
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"
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...
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 to and to it is the same thing...
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...
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:
I hope you understand it , it is known that my english sucks but anyway  |
|