Jump to content

Dos batch help

Gigabiter
Go to solution Solved by JFischer00,

PAUSE

Put it at the end.

im trying to make a calculator for my first program, and the cmd opens, then instantly closes.

@echo off
echo /p MATH=equation?
echo /a RESULT=%MATH%
echo %RESULT%

 

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

dude, it closes at the start, i put a pause, at the start, then i tried the end, and it just closes, as soon as the code runs, it flashes then closes

2 minutes ago, JFischer00 said:

PAUSE

Put it at the end.

 

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Gigabiter said:

dude, it closes at the start, i put a pause, at the start, then i tried the end, and it just closes, as soon as the code runs, it flashes then closes

 

@echo off
echo /p MATH=equation?
echo /a RESULT=%MATH%
echo %RESULT%
PAUSE

This code works fine for me.

Link to comment
Share on other sites

Link to post
Share on other sites

okay, it shows the exact code you/i put in, then in say the pause sentence, then when you press a button, it closes it

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

what is happening?

 

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

this is so fucking confusing

 

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

just calculate numbers, im in the 5th grade and i want to impress my friends, thats it

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, Gigabiter said:

just calculate numbers, im in the 5th grade and i want to impress my friends, thats it

So, I input "10+1" and it outputs "11"?

Link to comment
Share on other sites

Link to post
Share on other sites

wait wtf? why does that work and no other bat file works at all?

 

SPECS

GPU:Msi r9 270x. PSU:corsair CX600M. CPU AMD-fx 8320. CASE: ultra etorQe mid tower. HDD:1tb barracuda.MOTHERBOARD:ASUS M5A97.

Link to comment
Share on other sites

Link to post
Share on other sites

You can't just put "10+1" and expect it to understand.

 

@echo off
SET /p num=enter first number?
SET /p num2=enter second number?
echo
echo 1. add
echo 2. subtract
SET /P M=Type 1, 2 then press ENTER:
IF %M%==1 GOTO ADD
IF %M%==2 GOTO SUB

:ADD
SET /A RESULT=%num%+%num2%
GOTO END

:SUB
SET /A RESULT=%num%-%num2%
GOTO END

:END
echo The answer is %RESULT%
Pause

 This should work i cannot test as i am on a chromebook, however i should not that this does not check if the user has put in a number so will likely crash if you put in a letter.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×