|Initially, it looks like you're entering a null-RETURN (ENTER), so obv. there will be no available operand.|
Then, well, there's lots of small mistakes, and some not-so-small. Small catagory: I would recommend "setlocal", so your var values don't get confused with global var values.I always recommend neutralizing a variable before SET /P. ECHO . just echoes a dot (maybe your intent?), ECHO. echos a null line-feed. And when you tried to echo ANS, you can't put spaces like you did: ECHO PREVIOUS % ANS %.
Your concept is excellent. I did change the name of var. ANS to X, so the user can apply the math to the current "subtotal" by invoking x in the string, like this, f/e: x+22. This will add 22 to to the current running total. X is just an example. You could still use ANS, but that's 3 letters to type instead of one. Here's my version of your calculator with the aforementioned issues addressed somewhat:
:: recommending "setlocal"
@ echo off & setlocal
echo TITLE (Leonine) Calculator!
echo - Welcome to (Leonine) calculator!
echo ENTER YOUR OPERAND
::always clear a var. before SET /P else it retains its previous value on a null-ENTER
Set /p sum=
:: this next enables a graceful "prog.term" exit when user enters a null
:: it might also be an exit-routine with a query like "done?" etc.
if not defined sum goto :xit
Set /a x=%sum%
echo Previous Answer accessible as X: %x%
:: it's always polite to restore the color to default
::====== end script
ps: you ARE aware that batch only does integer math. Division results will be truncated to integers.
message edited by nbrane