why is ECHO unexpected at this time? i can't figure out why?

October 16, 2014 at 14:24:30
Specs: Windows 7
ok, so i am making this program to ask me if i had school today or not, but when i try and run it it says ECHO UNEXPECTED and i cant find out why... please comment if you know why its doing that, and fix it, thank you....


@echo off
echo Did you have school today?
echo.
set/p ans=
echo.
if %ans% ==yes (echo Oh, how was it?
echo.
set/p B=
echo.
if %B% ==good (echo that is good...
echo.
echo what is your favorite subject? math, science, history, english?
echo.
set /p C=
echo.
if %C% ==math (echo Oh, cool.)
if %C% ==science (echo That is cool.)
if %C% ==history (echo Nice!)
if %C% ==english (echo That is great!))
if %B% ==great (echo That is great!
echo.
echo what is your favorite subject? math, science, history, english?
echo.
set /p C=
if %C% ==math (echo Oh, cool.)
if %C% ==science (echo That is cool.)
if %C% ==history (echo Nice!)
if %C% ==english (echo That is great!))
if %B% ==fun (echo Oh, that is cool.
echo.
echo what is your favorite subject? math, science, history, english?
echo.
set /p C=
if %C% ==math (echo? Oh, cool.)
if %C% ==science (echo That is cool.)
if %C% ==history (echo Nice!)
if %C% ==english (echo That is great!))
if %B% ==bad (echo Oh, I am sorry...)
if %B% ==boring (echo Oh....Sorry...)
if %B% ==dumb (echo That is terrible.))
if %ans% ==no (echo Oh, okay, well... nevermind.)

pause

message edited by JOE123


See More: why is ECHO unexpected at this time? i cant figure out why?

Report •

#1
October 16, 2014 at 18:52:35
Disclaimer: I'm pretty much a batch noob...

That being said, I found a few potential errors (maybe not, I just do it differently)

set/p ---> set /p

if %ans% ==yes ---> if "%ans%"=="yes"

if ~ (echo Oh, how was it? ---> if ~ (echo Oh, how was it?)

(and make sure to get rid of the double "))")

User Info Page Biography for full specs.


Report •

#2
October 16, 2014 at 19:02:48
unbalanced parentheses would be my guess... count forward +1 for each (, and bacward -1 for each ). If the result is not zero, you have imbalance.

Report •

#3
October 17, 2014 at 03:58:23
Leave ECHO on, and see where it blows up

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
November 5, 2014 at 14:39:55
echo on is a good start....also, i'm not used to seeing a period after solo echos as in 'echo.' .... the parser may see that as a whole word and not recognize it as just echo script command

Report •

#5
December 4, 2014 at 12:04:26
Obviously, your ( and ) are unbalanced

Report •

Ask Question