I am getting an infinite loop when executing this script and it is not stopping on the month.
Invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021)
The output should display all month names until you reach your current month. So to use May as an example, this is what the output should look like:
1 January 2 February 3 March 4 April 5 May
If I just have set /a month=%date:~4,2% and my date is September then I get this octal error. If I add the modulus the count just goes on and on and on infinitely. How do I fix this? I have tried if %month%==08 set /a month=8 but that didn't work either. I also tried set firstdig=%month:~0,1% and if firstdig==0 set /a month=%month:0=% but nothing.
@echo off
setlocal
REM Extract two digit month from system date
::set /a month=%date:~4,2%
set /a month=100%date:~4,2% % 100
REM establish a starting monthnameue for the COUNT variable
set count=1
REM Convert abbreviated month number into full month name
set monthname=%date:~4,2%
set map=01-January;02-February;03-March;04-April;05-May;06-June;07-July;08-August;09-September;10-October;11-November;12-December
call set monthname=%%map:*%monthname%-=%%
set monthname=%monthname:;=&rem.%
REM Process the loop until the COUNT is greater than the month number
:BEGINLOOP
IF %count% GTR %month% GOTO END
if %count%==1 set monthname=January
if %count%==2 set monthname=February
if %count%==3 set monthname=March
if %count%==4 set monthname=April
if %count%==5 set monthname=May
if %count%==6 set monthname=June
if %count%==7 set monthname=July
if %count%==8 set monthname=August
if %count%==9 set monthname=September
if %count%==10 set monthname=October
if %count%==11 set monthname=November
if %count%==12 set monthname=December
echo %count% %monthname%
set /a count=%count%+1
goto beginloop
:END
Aucun commentaire:
Enregistrer un commentaire