|
Joined: Feb 2003
Posts: 79
Babel fish
|
OP
Babel fish
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)
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Try this: 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.
|
|
|
|
Joined: Feb 2003
Posts: 79
Babel fish
|
OP
Babel fish
Joined: Feb 2003
Posts: 79 |
|
|
|
|
|