You get that because the alias is returning a null value.
If that is the exact code you are using, I suggest you change the line
to return the variable:
Note the % sign in the second.
Does that work?
Additionally you can probably do it much more easily by using $findfile, with N = 0 to return the number
$findfile(dir,wildcard,N,depth,@window | command)
so you need soemthing like
$findfile($scriptdir,name*.txt,0)
should return the number of name*.txt files in the path to your script.