Reputation: 11
@echo off
Title OutputWords
:Input
cls
echo Enter a number:
set /p input=
if %input% == "1" set /a word=One
if %input% == "2" set /a word=Two
if %input% == "3" set /a word=Three
if %input% == "4" set /a word=Four
if %input% == "5" set /a word=Five
if %input% == "6" set /a word=Six
if %input% == "7" set /a word=Seven
if %input% == "8" set /a word=Eight
if %input% == "9" set /a word=Nine
if %input% == "0" set /a word=Zero
goto Show
:Show
cls
echo Number: %word%
pause
goto Input
So how do I make it so that when I write a number, it says the number with words, why isn't this working?
Upvotes: 0
Views: 45
Reputation: 144
I think the dilemma is with the quotes around the numbers. Batch is very finicky about quotes and spacing-- try:
if %input%==1 set /a word=One
or
if "%input%"=="1" set /a word=One
Another problem you should be having, is that when you use set /a
, set
expects the value you store to be an equation, which it will evaluate. Since you aren't having it do math, try:
if %input%==1 set word=One
Hope this helps.
Upvotes: 2