as FiberOptics has said
//echo -a Total: $findfile(w:\gcapture\,gunz*,0,1) well likely do
how ever the code you gave was so bugged i felt you needed the spots pointed out
gunznum {
set %filenum 002 [color:blue]<-- should be using var %filenum = 002, global vas should only be used if needed between runs of a script[/color]
set %keepgoing 1 [color:blue]<-- same as above[/color]
while (keepgoing == 1 ) { [color:blue]<-- variables need there % sign at the front when refenced ie: %keepgoing[/color]
if ("W:\gcapture\gunz $+ %filenum == $null) { [color:blue]<-- need to use IF (!$isfile(W:\gcapture\gunz $+ %filenum))[/color]
set %returnv $calc(%keepgoing - 1) [color:blue]<--%keepgoing is always equals 1 so this is always going to result with 0, I assume your ment to be using %filenum[/color]
return returnv [color:blue]<-- var returnv needs the % added to it[/color]
break [color:blue]<-- well never occur RETURN (above) exits script[/color]
set %keepgoing 0[color:blue]<-- well never occur RETURN (above) exits script[/color]
}
else {
inc filenum [color:blue]<-- var filenum needs the % added to it, also 002 well result in 3, so a following command of VAR %filenum = $right(00 $+ %filenum,3) [/color]
}
}
}
heres a code rewrite using your code
[code]
gunznum {
var %filenum = 002
var %keepgoing = 1
while (keepgoing == 1) {
if (!$isfile(W:\gcapture\gunz $+ %filenum)) {
var %returnv = $calc(%filenum - 1)
return %returnv
}
else {
inc %filenum | if (%filenum == 1000) { return 999 }
var %filenum = $right(00 $+ %filenum,3)
}
}
}
[code]
* code untested *
Added a protection from endless loop with the checking if moving beyond file 999