Why does simple code not work?

March 27, 2012 at 20:11:51
Specs: Windows 7
Why does this not work? I type things in but the variables ALWAYS show as blank! It should be working but it just doesn't!

echo.Fun?
choice /C:12345 /N
set fun = %errorlevel%
echo.*Notes on fun?
set /p funn = ""
echo.Originality?
choice /C:12345 /N
set orig = %errorlevel%
echo.*Notes on Originality?
set /p orign = ""
echo.Content?
choice /C:12345 /N
set cont = %errorlevel%
echo.*Notes on Content?
set /p contn = ""
echo.Graphics?
choice /C:12345 /N
set grap = %errorlevel%
echo.*Notes on Graphics?
set /p grapn = ""
echo.Sound?
choice /C:12345 /N
set sound = %errorlevel%
echo.*Notes on Sound?
set /p soundn = ""
set /a over = (%fun% + %orig% + %cont% + %grap% + %sound%) / 5


See More: Why does simple code not work?

Report •

#1
March 27, 2012 at 20:34:31
You need to use double quotes:

set /a over = ("%fun%" + "%orig%" + "%cont%" + "%grap%" + "%sound%") / 5

Tony


Report •

#2
March 28, 2012 at 00:24:56
Like I tried to tell you in the other thread the spaces you are using around your set statements are not ignored by cmd.

set fun = %errorlevel%
echo [%fun%] - Brackets should be empty
echo [%fun %] - Look the spaces are part of the variable name and it's content.

Stop putting spaces around the "=" sign with the set command and you code may have a chance of working.


Report •

#3
March 28, 2012 at 00:28:17
Judago beat me to it...

Report •
Related Solutions


Ask Question