Returns the Nth token or amount of tokens in a string.
Where N is the Nth token you wish to be returned from the string by delimiter C. Alternatively N can be given as 0 to return the amount of tokens in the string.
For more information about the delimiters, see $chr.
$gettok(Ave:IT,1,58) ;returns Ave
This returns the first token using $chr(58) as the delimiter, which is character :
$gettok(Ave:IT,0,58) ;returns 2
This returns the value 2 because there are two values delimited by a $chr(58)
Note: N can be a range N1-N2. Examples where the delimiter is $chr(32) (a space):
$gettok(Word1 Word2 Word3 Word4,2-3,32) ;returns Word2 Word3 From word 2 until word 3. $gettok(Word1 Word2 Word3 Word4,3-,32) ;returns Word3 Word4 From the third word until the end. $gettok(Word1 Word2 Word3 Word4,-2-,32) ;returns Word3 Word4 From the second-to-last word, until the end. $gettok(Word1 Word2 Word3 Word4,-3--2,32) ;returns Word2 Word3 From the third-to-last word, until the second-to-last word.
Note: Although it may seam resonable to use -3-4 in this situation to get the third-to-last word (Word2) until the forth word (Word4), $gettok() does not calculate it this way, you will end up with the same as -3-. You can only use a negative to value if you have a negative from value and the to value much be greater than the from yet still negative. eg:
$gettok(Word1 Word2 Word3 Word4,-3--2,32) ; Works. $gettok(Word1 Word2 Word3 Word4,-3--3,32) ; Works. although it would be the same as -3 $gettok(Word1 Word2 Word3 Word4,-3--4,32) ; Doesn't work, since -4 (the to value) is smaller than -3 (the from) it fails. $gettok(Word1 Word2 Word3 Word4,-3-1,32) ; Doesn't work, since 1 is not negative.
When you give a negative from value you start grabbing information from the end, it seems giving a positive number for the to value would try and count from the end posistion also although it jumps past the end.
$gettok(Word1 Word2 Word3 Word4,-3-1,32) It looks like in this example, mIRC finds the from value as negative, jumps to the end of the string, and jumps back 3 positions and marks this as the start value, then also going from the end position it finds 1 as positive so it jumps forward 1 which is past the end of the string, it which would be, if there was one, the 5th token.