# Batch file - entering a space closes the command prompt?



## nappymonster (Jul 15, 2007)

Hi all

I have virtually no knowledge of programming batch files, so i thought i would make a little test app - just a very simple quiz (questions taken from Pub Quiz Machine 2004)

After using my mum as a beta tester (to iron out the bugs before i added more questions, extra bits etc). It took alot of attempts but i finally found and fixed (what i hope is) all the bugs - except one.

If (when it asks you for an input) you enter a space, it exits the command prompt.

Are there any known fixes to this? Is this a common problem or is it something that can't be fixed.

I based it on who wants to be a millionaire - and yes i am aware it's kinda corny - its more for learning than anything.





@echo off

:intro
cls
echo Hello, and welcome to...
echo.
echo.
echo ***************************************
echo * *
echo * Who Wants To Be A Millionaire *
echo * *
echo ***************************************
COLOR 1f
PING 1.1.1.1 -n 1 -w 10 >NUL
COLOR 2F
PING 1.1.1.1 -n 1 -w 10 >NUL
COLOR 3F
PING 1.1.1.1 -n 1 -w 10 >NUL
COLOR 0f


PING 1.1.1.1 -n 1 -w 3000 >NUL
:choosequestions
echo Which set of questions would you like to play?
Set choice=
Set /p choice= 1, 2, 3, 4 or 5? 

if '%choice%'=='1' goto g1q1
if '%choice%'=='2' goto g1q1
if '%choice%'=='3' goto g1q1
if '%choice%'=='4' goto g1q1
if '%choice%'=='5' goto g1q1

echo %Choice% is not a vaild option! Try again...
goto choosequestions
:gameshow1
:g1q1
echo For 100 Pounds: What name is given to the imaginary line that runs around the middle of the earths surface?
echo A: Curator
echo B: Relator
echo C: Equator
echo D: Negator
Set choice=
Set /p choice= A, B, C or D?
if '%choice%'=='A' goto nothing
if '%choice%'=='B' goto nothing
if '%choice%'=='C' goto g1q2
if '%choice%'=='D' goto nothing
if '%choice%'=='a' goto nothing
if '%choice%'=='b' goto nothing
if '%choice%'=='c' goto g1q2
if '%choice%'=='d' goto nothing

echo %Choice% is not a vaild option! Try again...
Ping 1.1.1.1 -n 1 -w 2000 >NUL
goto g1q1

:g1Q2 
echo That is correct! You now have 100 Pounds
PING 1.1.1.1 -n 1 -w 5000 >NUL
echo For 200 Pounds: Which organ in the human body pumps blood around the body?
echo A: Heart
echo B: lungs
echo C: liver
echo D: kidney
Set choice=
Set /p choice= A, B, C, D or W?
if '%choice%'=='A' goto g1q3
if '%choice%'=='B' goto nothing
if '%choice%'=='C' goto nothing
if '%choice%'=='D' goto nothing
if '%choice%'=='a' goto g1q3
if '%choice%'=='b' goto nothing
if '%choice%'=='c' goto nothing
if '%choice%'=='d' goto nothing
if '%choice%'=='w' goto 100
if '%choice%'=='W' goto 100
echo %Choice% is not a vaild option! Try again...
Ping 1.1.1.1 -n 1 -w 2000 >NUL
goto g1q3


:g1q3
echo That is correct! You now have 200 Pounds
PING 1.1.1.1 -n 1 -w 5000 >NUL
echo For 300 Pounds: Which family reached top of the charts with "Do the bartman"?
echo A: The Jacksons
echo B: The Simpsons
echo C: The Smiths
echo D: The flintstones
Set choice=
Set /p choice= A, B, C, D or W?
if '%choice%'=='A' goto nothing
if '%choice%'=='B' goto g1q4
if '%choice%'=='C' goto nothing
if '%choice%'=='D' goto nothing
if '%choice%'=='a' goto norhing
if '%choice%'=='b' goto g1q4
if '%choice%'=='c' goto nothing
if '%choice%'=='d' goto nothing
if '%choice%'=='w' goto 200
if '%choice%'=='W' goto 200
echo %Choice% is not a vaild option! Try again...
Ping 1.1.1.1 -n 1 -w 2000 >NUL
goto g1q3

:g1q4
echo That is correct! You now have 300 Pounds
PING 1.1.1.1 -n 1 -w 5000 >NUL
echo For 500 Pounds: What food is traditionally server during thanksgiving?
echo A: Chicken
echo B: Beef
echo C: Pork
echo D: Turkey
Set choice=
Set /p choice= A, B, C, D or W?
if '%choice%'=='A' goto nothing
if '%choice%'=='B' goto nothing
if '%choice%'=='C' goto nothing
if '%choice%'=='D' goto g1q5
if '%choice%'=='a' goto norhing
if '%choice%'=='b' goto nothing
if '%choice%'=='c' goto nothing
if '%choice%'=='d' goto g1q5
if '%choice%'=='w' goto 300
if '%choice%'=='W' goto 300
echo %Choice% is not a vaild option! Try again...
Ping 1.1.1.1 -n 1 -w 2000 >NUL
goto g1q5

:g1q5
echo That is all there is at the moment!
Set choice=
Set /p choice= Try again? Y/N
if '%choice%'=='Y' goto intro
if '%choice%'=='y' goto intro
if '%choice%'=='N' goto end
if '%choice%'=='n' goto end


:nothing
echo That answer is incorrect!
echo So unfortunately, today you go home with nothing
goto playagain

:100
echo So at the end of tonight you go home with 100 pounds!
goto playagain

:200
echo So at the end of tonight you go home with 200 pounds!
goto playagain

:300
echo So at the end of tonight you go home with 300 pounds!
goto playagain

:500
echo So at the end of tonight you go home with 500 pounds!
goto playagain

:1000
echo So at the end of tonight you go home with 1000 pounds!
goto playagain

:2000
echo So at the end of tonight you go home with 2000 pounds!
goto playagain

:4000
echo So at the end of tonight you go home with 4000 pounds!
goto playagain

:8000
echo So at the end of tonight you go home with 8000 pounds!
goto playagain

:16000
echo So at the end of tonight you go home with 16000 pounds!
goto playagain

:32000
echo So at the end of tonight you go home with 32000 pounds!
goto playagain
:64000
echo So at the end of tonight you go home with 64000 pounds!
goto playagain

:125000
echo So at the end of tonight you go home with 125000 pounds!
goto playagain

:250000
echo So at the end of tonight you go home with 250000 pounds!
goto playagain

:500000
echo So at the end of tonight you go home with 500000 pounds!
goto playagain

:1000000
echo Congratulations! You won the 1,000,000 pound prize!
goto playagain

layagain
Set choice=
Set /p choice= Try again? Y/N
if '%choice%'=='Y' goto intro
if '%choice%'=='y' goto intro
if '%choice%'=='N' goto end
if '%choice%'=='n' goto end
echo %Choice% is not a vaild option! Try again...
goto playagain




:end






Try out if you want and let me know if you find any other bugs.

Thanks in advanced,

Nappymonster


----------

