;GettokFix by Mascovy ; - This sniplet will return Nth Token in text eiher the token exist or not ; For example ... ; (this is what $fgettok will return) ; $fgettok(this.only.the.example,2,46) return only ; $fgettok(this..the.example,2,46) return $null ; ; (this is what $gettok will return) ; $gettok(this..the.example,2,46) return the ; ;So can you Spot the difference with this 2 example ;USAGE: $fgettok(text,N,C) ... This will Returns the Nth token in text] ;This identifier is same usage like $gettok so N can be negative value, and range ;between 2N (N-N or N-) - ; mascovy ; mindforce83@yahoo.com ; https://mascovy.tripod.com/ fgettok { if (!$isid) fgettok ;Error Reply if Not Enough parameter if (!$2) || (!$3) { echo $color(info) * Too few parameters: $+($chr(36),fgettok) | halt } ;$gettok reply if C=32 or C=160 , (I dont think user need to get character 'space' to seperate ;the text if ($istok(32.160,$3,46)) return $gettok($1,$2,$3) if ($2 == 1-) return $1 var %t = $3 , %g = $count($1,$chr(%t)) , %tl = $len($1) , %c = 0 , %h = 0 , %kul var %s = $iif($left($2,1) == -,$remove($2,-),$gettok($2,1,45)) , %e = $iif($right($2,1) == -,%g,$gettok($2,2,45)) ;Free Hash Table if Exist (This hash store the token) if ($hget(fgettok)) hfree fgettok ;While will loop to get and catch the token while (%c < %tl) { inc %c | var %oc = $right($left($1,%c),1) | if (%oc !== $chr(%t)) %kul = $iif($asc(%oc) != 32 && $asc(%oc) != 160,$+(%kul,%oc),$addtok(%kul,%oc,32)) | if (%oc === $chr(%t)) || (%c == %tl) { inc %h | hadd -m fgettok %h $iif(%kul,%kul,$null) | unset %kul } } ;Done and sniplet will display the result if (- !isincs $2) return $hget(fgettok,$2) if ($right($2,1) isnum) && ($left($2,1) == -) { var %n = 0 , %xc | while (%n < %s) { inc %n | %xc = $+(%xc,$iif(%xc,$chr($3),),$hget(fgettok,%n)) } | return %xc } if ($right($2,1) == -) && ($left($2,1) == -) { var %n = 0 , %k = $hget(fgettok,0).data , %g = $remove($2,-) , %xc | while (%n < %k) { inc %n | var %lf = $calc(%k - %n + 1) | if (%n <= %g) %xc = $+($hget(fgettok,%lf),$iif(%xc,$chr($3),),%xc) } | return %xc } if (%e) { var %xc | while (%s < $calc(%e + 1)) { %xc = $+(%xc,$iif(%xc,$chr($3),),$hget(fgettok,%s)) | inc %s } | return %xc } ;EOI }