mIRC Home    About    Download    Register    News    Help

Print Thread
#113305 03/03/05 02:48 PM
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
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)

#113306 03/03/05 02:58 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.

#113307 03/03/05 03:02 PM
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
Much better, thanks.


Link Copied to Clipboard