mIRC Homepage
Posted By: Ancyker Problem with $gettok - 03/03/05 02:48 PM
My problem is I'm trying to read a file, the file contains comma seperated lines, and it seems $gettok ignores the null tokens...

Exmaple:
ID,,,,1,,,,,,2,3,,,4,,,,5,

value 1 would return "ID", value 2 would return 1 instead of null, value 3 would return 2 instead of null, etc

I want it just to return null or return a 0 (either is fine)
Posted By: FiberOPtics Re: Problem with $gettok - 03/03/05 02:58 PM
Try this:

Code:
alias fgettok {
  if $remove($2,-) !isnum || $3 !isnum 1-255 { return }
  var %a = $+(\Q,$chr($3),\E), %b = $regsub($1,/(?<= %a |^)(?= %a |$)/gx,$lf,%a)
  return $remove($gettok(%a,$2,$3),$lf)
}

//var %a = ID,,,,1,,,,,,2,3,,,4,,,,5, | echo -a -> $fgettok(%a,5,44) will return 1, whereas normally it would be the second token.
Posted By: Ancyker Re: Problem with $gettok - 03/03/05 03:02 PM
Much better, thanks.
© mIRC Discussion Forums