I'm trying to write a small factoring script, but for some reason the while loop isn't reading the variables correctly. The variables are definitely storing the correct information they just aren't being passed correctly it seems:
alias factorial {
set %factor.input $1-
set %factor.loop 0
set %factors.count 1
if ($calc(%factor.input != 0)) {
%input.str.len = %factor.input
goto numbers
}
echo -a 4letters
%input.str.len = $len(%factor.input)
:numbers
%factor = %input.str.len
while ( %factors.count <= %input.str.len )
{
%factor = $calc(%factor * $calc(%input.str.len - %factors.count))
inc %factors.count
}
return %factor
}
This will work fine if you try doing it manually through the input box, but not as an alias or an identifier. Any ideas as to where I'm screwing up would be greatly appreciated.