dos for 语句嵌套出错.
@echo off
set yy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%
set /a yy%%=400
if %yy% equ 0 (set rdd=29) else (set rdd=28)
set str=31/%rdd%/31/30/31/30/31/31/30/31/30/31
for /l %%i in (1,1,%mm%) do (
echo %%i
set/a mon=%%i-1
for /f "tokens=%mon% delims=/" %%x in ("%str%") do (
echo %%x
)
)
pause
将蓝色一段放在第一个for里面提示"不应有delims=/"
如果把他放在第一个for外面就不会有问题..
请各位高手帮帮忙,帮小弟看一下,到底是怎么回啊.谢谢了
------解决方案--------------------[code=BatchFile]
@echo off
SETLOCAL
set yy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%
set /a yy%%=400
if %yy% equ 0 (set rdd=29) else (set rdd=28)
set str=31/%rdd%/31/30/31/30/31/31/30/31/30/31
for /l %%i in (1,1,%mm%) do (
echo %%i
call :MON %%i %str%
)
:MON
for /f "tokens=%1 delims=/" %%x in ("%2") do echo %%x
goto :EOF
:EOF
ENDLOCAL
[/code]