Computing.Net > Forums > Programming > Batch File Variable Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Variable Help

Reply to Message Icon

Name: Impulse
Date: February 6, 2009 at 15:00:01 Pacific
OS: Windows XP Pro SP2
CPU/Ram: AMD Semptron - 1.5gb RAM
Product: E-machines / T3120
Subcategory: Batch
Comment:

Hi,
I'm making a batch file in which a variable is stored and then a
number is subtracted from it. Lets say I made a variable called
MyVar and then if someone goes to a certain section, then a
number is subtracted from it.
E.X:

@echo off
set MyVar=70
echo Hello! Please select an option...
echo.
echo 1 - Go!
echo 2 - Exit
set input=
set /p input=Selection:
if %input%==1 goto go
if %input%==2 goto exit

:go
*** Subtracting Code Here ***
cls
echo 60 has been subtracted from MyVar
echo The Variable is now: %MyVar%
ping localhost -n 4 >nul

:exit
cls
exit

So how would I go about doing that?

If you give up, might as well give up everything in life.



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: February 6, 2009 at 16:49:51 Pacific
Reply:

set /a myvar-=<number>

Just be aware that set /a has large number limitations, for 32 bit windows anything outside of -2147483648 to 2147483647 may cause problems.


0
Reply to Message Icon

Related Posts

See More


Help with batch script batch autorun and autopla...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Variable Help

Batch file variable creation www.computing.net/answers/programming/batch-file-variable-creation/14564.html

Simple Batch File command help www.computing.net/answers/programming/simple-batch-file-command-help/16568.html

Nesting variables in batch files ? www.computing.net/answers/programming/nesting-variables-in-batch-files-/14334.html