312Views24Replies

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

Discussions

0
None
chooseausername

10 years ago

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 ?

0
None
chooseausernamedsman195276

Reply 10 years ago

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

0
None
zachninmechooseausername

Reply 10 years ago

`wine test.bat`

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

0
None
Goodhartchooseausername

Reply 10 years ago

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

0
None
dsman195276

10 years ago

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

0
None
NachoMahma

10 years ago

. 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.

0
None
Goodhartdsman195276

Reply 10 years ago

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
)

0
None
dsman195276Goodhart

Reply 10 years ago

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.

0
None
Goodhartdsman195276

Reply 10 years ago

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.

0
None
dsman195276Goodhart

Reply 10 years ago

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

0
None
Goodhartdsman195276

Reply 10 years ago

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

0
None
KentsOkay

10 years ago

Ehh... gota syntax error...

0
None
dsman195276KentsOkay

Reply 10 years ago

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

0
None
dsman195276KentsOkay

Reply 10 years ago

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

0
None
dsman195276KentsOkay

Reply 10 years ago

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

0
None
chooseausername

10 years ago

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