adding up in batch

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
hey all,

I need to add some numbers together in a dos batch file.

any ideas how???

i thought..

set sum=%var1% + %var2%

but that just makes a variable with "10 + 90" and not the required 100.

cheers in advance.
 
almost...

set /a sum=%var1%+%var2%

yeah. You don't need the qualifiers ( %) if you are using set /a but they can be useful.

Also, in a FOR loop if you may need to use SETLOCAL ENABLEDELAYEDEXPANSION for it to work, depending on the circumatance,

check dostips.com and ss64.com for details.
 
Back
Top Bottom