Alf said:
Thanks. Just a follow up question, how do I set the output
back to default.
ex. set /a 1000+2000 = 3000. Needed output is 3,000.
thanks again.
Read the syntax built-in to the SET command, using "SET /?". You can use :~
to do variable substitution. This will handle numbers under 1 trillion
(999,999,999,999).
Remove the line numbers (use them to identify unwanted line
wraps)
01. @Echo Off
02. SetLocal EnableExtensions
03. Set /a TOTAL=1000+2000
04. Echo %TOTAL%
05. Call :_ADD_COMMAS %TOTAL% TOTAL
06. Echo %TOTAL%
07. GoTo :EOF
08.
09. :_ADD_COMMAS
10. Set BUFFER=%1
11. If Not Defined BUFFER Set BUFFER=0
12. If Not "%BUFFER:~0,-3%" == "" Set BUFFER=%BUFFER:~0,-3%,%BUFFER:~-3,3%
13. If Not "%BUFFER:~0,-7%" == "" Set BUFFER=%BUFFER:~0,-7%,%BUFFER:~-7,7%
14. If Not "%BUFFER:~0,-11%" == "" Set
BUFFER=%BUFFER:~0,-11%,%BUFFER:~-11,11%
15. Set %2=%BUFFER%
16. GoTo :EOF