14 Jun 2008 at 20:23 #1 blastman blastman 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.
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.
14 Jun 2008 at 20:35 #2 matja matja Associate Joined 29 Sep 2005 Posts 819 Location St Neots / Dublin almost... set /a sum=%var1%+%var2%
15 Jun 2008 at 00:02 #3 whitecrook whitecrook Soldato Joined 22 Aug 2005 Posts 8,969 Location Clydebank matja said: almost... set /a sum=%var1%+%var2% Click to expand... 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.
matja said: almost... set /a sum=%var1%+%var2% Click to expand... 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.