2

Every time I try playing it exits instead of moving on to the next line when I clik enter; it works fine until after you enter your name, then it skips to question 1, then it exits. I'm not an expert on this so I would like to know what I'm doing wrong and how to fix it. If you notice any other mistakes please feel free to point them out. Thanks! :)

@echo off color F0 cls echo. echo True or False pause echo Welcome! May I ask your name before we begin? echo. set /p name= echo. echo Hello %name%, nice to meet you! echo. echo My name is Myst. echo. cls echo. echo Let us begin! :start color FC cls echo. echo QUESTION 1 pause echo. echo Though hard, you can start a fire by rubbing 2 cool ranch doritos together for a long time. echo. echo TRUE or FALSE echo. set /p variable= echo. if %variable% equ TRUE goto question2 if %variable% equ FALSE goto answer1 if %variable% neq TRUE goto start :answer1 cls echo. echo Wrong! Though it is very hard, it is possible. goto start :question2 color F3 cls echo QUESTION 2 pause echo. echo Singing in the shower lowers your cholesterol, heart rate, & risk of cancer and heart disease. echo. echo TRUE or FALSE echo. set /p variable= echo. if %variable% equ TRUE goto answer2 if %variable% equ FALSE goto question3 if %variable% neq TRUE goto question2 :answer2 cls echo. echo Wrong! echo. echo Here is a fast fact for you %name%. Dark chocolate doesn't either. goto start :question3 color F5 cls echo QUESTION 3 pause echo. exit 
4
  • That is not how you paste code! Please paste it again, and then highlight it, and press ctrl+k, or click the {} button Commented Apr 22, 2013 at 3:53
  • Well I said I didn't know how, sorry. Thank yall for the help though. Commented Apr 22, 2013 at 3:59
  • Yeah sorry, didn't mean to come across so abruptly. Thanks for fixing it! Commented Apr 22, 2013 at 4:02
  • It's ok and no problem! Commented Apr 22, 2013 at 22:55

3 Answers 3

2

You had some syntax errors and various issues. Try this as an example: it has some changes and edits to make it more robust.

@echo off color F0 cls echo. echo True or False echo. set /p "name=Welcome! May I ask your name before we begin? " echo. echo Hello %name%, nice to meet you! echo. echo My name is Myst. echo. echo. ping -n 3 localhost >nul echo Let us begin! pause :start color FC cls echo. echo QUESTION 1 echo. echo Though hard, you can start a fire by rubbing 2 cool ranch echo doritos together for a long time. echo. echo. set /p "variable=TRUE or FALSE: " echo. if /i "%variable%" equ "TRUE" ( echo Right! pause goto :question2 ) cls echo. echo Wrong! Though it is very hard, it is possible. pause :question2 color F3 cls echo QUESTION 2 echo. echo Singing in the shower lowers your cholesterol, heart rate, & echo risk of cancer and heart disease. echo. set /p "variable=TRUE or FALSE: " echo. if /i "%variable%" equ "FALSE" ( echo Right! pause goto :question3 ) echo cls echo. echo Wrong! echo. echo Here is a fast fact for you %name%. Dark chocolate doesn't echo either. pause :question3 color F5 cls echo QUESTION 3 pause echo. exit 
Sign up to request clarification or add additional context in comments.

Comments

2

Try this:

if "%variable%" equ "TRUE" goto :question2 if "%variable%" equ "FALSE" goto :answer1 goto :start 

Comments

1
echo Hello %name%, nice to meet you! echo. echo My name is Myst. echo. 

cls

echo. echo Let us begin! 

The CLS command makes to clean the window, so you can read nothing. Also you need to stop the execution of the script (with a pause).

You are using the cls command too many times without pausing the code.

Also you need to try to don't make a intelligible code like that, you need to make indentations, make empty lines, to let us understand the code.

And no need to use string recognitions like "true or false?" because exist a type of variable called "Boolean" and that is only True/False, you can use boolean questions with the Choice command.

Really you need to rewrite it all the code again because you can see things like this:

if %variable% equ TRUE goto answer2 if %variable% equ FALSE goto question3 if %variable% neq TRUE goto question2 

if variable only can be "true" and "False" then the third conditional never will be processed, no need to be a pro to understand it, is logical.

And think about what happens if the user type "true" or "TrUe" or any variant?

Then you will need to use the /I parameter of "IF" statement.

If /I EQU "True" (Goto...) ELSE (Goto...) 

And you are using the operator "&" to print a string using echo command, but you can't print operators without using double-quoues or escaping the character:

Echo "&" Echo ^& 

Too many thing more for explain but the big problem of your code is that you've missed like 10 "pause" needed to read the strings.

PS: Sorry for my english.

Here is the corrected code:

@Echo off Color F0 Echo+ Echo: True or False | MORE Pause & CLS Echo+ Echo: Welcome! May I ask your name before we begin? | MORE set /p "name=" & CLS Echo+ Echo: Hello %name%, nice to meet you! | MORE Echo: My name is Myst. | MORE Pause & CLS Echo+ Echo: Let us begin! Pause & CLS :start color FC Echo+ Echo: QUESTION 1 Pause Echo+ Echo: TRUE or FALSE | MORE Choice /C TF /M "Though hard, you can start a fire by rubbing 2 cool ranch doritos together for a long time." if %ERRORLEVEL% EQU 1 (Goto Question2) ELSE (goto Answer1) :answer1 cls Echo+ Echo: Wrong! Though it is very hard, it is possible. Pause & CLS Goto :start :question2 color F3 cls Echo: QUESTION 2 pause Echo+ Echo: TRUE or FALSE | MORE Choice /C TF /M "Singing in the shower lowers your cholesterol, heart rate, & risk of cancer and heart disease." if %ERRORLEVEL% EQU 1 (Goto answer2) ELSE (goto question3) :answer2 cls Echo+ Echo: Wrong! | MORE Echo: Here is a fast fact for you %name%. Dark chocolate doesn't either. Pause & CLS goto start :question3 ... ... ... 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.