AceInfinity
Emeritus, Contributor
Here's a function I created in order to help prevent this fun error you get from numbers being interpreted indifferently.
This is commonly caused by leading zero's in a number. So here's my example use of the function i've created:
Invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021).
This is commonly caused by leading zero's in a number. So here's my example use of the function i've created:
Code:
@echo off
setlocal enabledelayedexpansion
set n=000100
echo Original: %n%
call :RemLeadingZeros %n% n
echo After Call To RemLeadingZeros: %n%
echo.
pause && goto :eof
:RemLeadingZeros
set num=%1
set /a n=0
:tryagain
set newnum=!num:~%n%!
if not defined newnum ( set %2=0 && goto :eof )
if %newnum:~0,1% neq 0 ( set %2=%newnum% && goto :eof )
set /a n+=1
goto tryagain