287Views24Replies

Author Options:

my batch Answered

i have been playing around with batch coding for a month now and i finaly finished and figered out everything i need to do to get this to work. so here it is.

@ECHO OFF
color 0a
:top
echo -----------------------------------------------
echo type the number 1 for a number guessing game
echo type the number 2 for a calculator
echo type the number 3 to see a dumb thing a made up.
echo type the number 4 to exit.
echo this is a free-to-use program
echo give all credit to dsman1
echo do not edit with out dsman1's consent
echo -----------------------------------------------
set variable1=1
set variable2=y
set variable3=n
set variable4=3
set variable5=2
set variable7=0
set variable9=4
set /p udefine=
if %udefine%==%variable1% (
goto game
)
if %udefine%==%variable5% (
goto calc
)
if %udefine%==%variable4% (
goto starwars
)
if %udefine%==%variable9% (
exit
)
:calc
echo hi and wellcome to calcualtor
echo credit for programing goes to dsman1
echo -----------------------------------------------
echo mutiply = *
echo divide = /
echo add = +
echo subtract= -
echo parenthesis can be in your problems.
:loop
echo -----------------------------------------------
SET /p UDefine=
echo =
SET /a UDefine=%UDefine%
ECHO %UDefine%
echo math is fun
ECHO.
echo again? y/n
set /p udefine=
if %udefine%==%variable2% (
goto loop
) else (
goto top
)
:game
@ECHO OFF
SET /a GuessNum=0
SET /a Answer=%random%
ECHO Guess what Number I'm thinking of.
:Retry
SET /p Guess=
IF %Guess% LSS %Answer% ECHO My Number is Higher.
IF %Guess% GTR %Answer% ECHO My Number is Lower.
IF %Guess%==%Answer% GOTO END
ECHO.
SET /a GuessNum=%GuessNum%+1
GOTO Retry
:END
ECHO You are Correct! The Answer was %Answer%
ECHO It took %GuessNum% Guesses.
ECHO.
echo play again? y/n
set /p udefine=
if %udefine%==%variable2% (
goto game
) else (
goto top
)
:starwars
echo dont press a button
pause
echo ok please
pause
echo please with suger on top
pause
echo ok come on now
pause
echo you are just trying to irritate me
pause
echo and it's working...
pause
echo i will blow you up in...
pause
echo 5
pause
echo 4
pause
echo 3
pause
echo 2
pause
echo 1
pause
echo boom!!!
pause
echo haha
pause
echo your dead!
pause
echo try to push a button now!
pause
echo darn
pause
echo
echo / you will die mortal \
echo / mahaha \
echo / \
echo
pause
set /a variable6=500
:hehe
set /a variable6=%variable6%-1
echo hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
if %variable6%==0 goto :haha
goto hehe
:haha
echo play again? y/n
set /p udefine=
if %udefine%==%variable2% (
goto starwars
) else (
goto top
)

copy that and paste it into note pad. save it with .bat at the end. save it to your desktop and then click on it.

this is what the code looks like. me copying the code messed it up. so please just download the .exe verson

[www.dsman1.webs.com/calc.exe download]

Tags:mybatch

24 Replies

user
chooseausername (author)2008-02-29

It does not work. When I double click on it, it does not execute. Instead Gedit is opened with all the code inside. What am I supposed to do ?

Select as Best AnswerUndo Best Answer

user

you have to save it as a .bat file not a .txt file.

Select as Best AnswerUndo Best Answer

user

That's what I've done. The filename is test.bat, and when I double click, it's Gedit that show up ... Any clue ?

Select as Best AnswerUndo Best Answer

user

You have to downgrade your operating system xD

Select as Best AnswerUndo Best Answer

user

`wine test.bat`

*evil laughter*
Linux, doing everything you do, but better

Select as Best AnswerUndo Best Answer

user
Goodhart (author)chooseausername2008-02-29

One thing, you are running under Linux, correct ? The bat file runs under the Window OS, I am not sure about Linux

Select as Best AnswerUndo Best Answer

user
Goodhart (author)chooseausername2008-02-29

BTW: you gave it away by mentioning Gedit LOL

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)2008-03-01

every one please download the .exe file from the website.

Select as Best AnswerUndo Best Answer

user
NachoMahma (author)2008-02-29

. Good job. Be nice to know what the range is for the number guessing game. 0-32767? And for those that are unfamiliar with batch files, include a "Press ctrl-C to exit" line in the menu.

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)NachoMahma2008-02-29

the range is 10000 to 99999.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)dsman1952762008-02-29

As Nahco wrote, having an "exit" of some sort at the beginning is helpful,
the following should work:

echo type the number 4 to EXIT

set variable8=4

if %udefine%==%variable8% (
exit
)

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)Goodhart2008-02-29

that works already. you dont need to do all that.
if the number does not = one of the variables(1,2, or 3) the defalt closes the program. but i will put that in the coding.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)dsman1952762008-02-29

Actually, it defaults to the
mutiply = *
divide = /
add = +
subtract= -
parenthesis can be in your problems.

segment, the way you have it. If you look at the code carefully, you will see why it does this.

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)Goodhart2008-02-29

yea. i dont know y it does. it dident use to. but any way i add the exit thing.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)dsman1952762008-02-29

without the exit, it would simply "go on to the next instruction", since no line told it to go anywhere else.

Select as Best AnswerUndo Best Answer

user
KentsOkay (author)2008-02-29

Ehh... gota syntax error...

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)KentsOkay2008-02-29

www.dsman1.webs.com/calc.exe you can download the .exe file there.

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)KentsOkay2008-02-29

o i see not. its the copying glitch! it messed up the code. i will rewrite it.

Select as Best AnswerUndo Best Answer

user
dsman195276 (author)KentsOkay2008-02-29

i wonder why that happend. make sure that you copyed the code right.

Select as Best AnswerUndo Best Answer

user
chooseausername (author)2008-02-29

I ran Windows just to try your batch : Nice work ! At last someone who uses batch to make something cool !

Select as Best AnswerUndo Best Answer