恩,我还是继续坚持下去,本着共享的精神-_-||
前面反复说到call,set的效率问题,今天试着用for循环替换call,set,发现效率提高很多。通过运用for的嵌套,相信在效率影响比较大的场合,可以基本抛弃call,set了。
@echo off
setlocal enabledelayedexpansion
set template=?a??b???c????d?????e??????f???????g????????h?????????i??????????j???????????k????????????l?????????????m??????????????n???????????????o????????????????p?????????????????q??????????????????r???????????????????s????????????????????t?????????????????????u??????????????????????
set template=!template:?=:?!
set template=!template:?:=/!
set template=!template::=!
for /l %%a in (1,1,1001) do (
set file=%template%
set temp=%%a:::::::::%%a
for %%b in (!temp:~10!) do set file=!file:?=%%b!
for /l %%i in (1,1,9) do set file=!file:/:=!
set file=!file:/=0!
set file=!file::=!
echo !file!
echo.
)
pause
Last edited by obsolete on 2008-7-31 at 11:15 PM ]
Well, I still continue to persevere, with the spirit of sharing -_-||
The efficiency issues of call and set were repeatedly mentioned earlier. Today, I tried replacing call and set with for loops and found that the efficiency improved a lot. By using nested for loops, I believe that in occasions where efficiency has a relatively large impact, call and set can basically be abandoned.
@echo off
setlocal enabledelayedexpansion
set template=?a??b???c????d?????e??????f???????g????????h?????????i??????????j???????????k????????????l?????????????m??????????????n???????????????o????????????????p?????????????????q??????????????????r???????????????????s????????????????????t?????????????????????u??????????????????????
set template=!template:?=:?!
set template=!template:?:=/!
set template=!template::=!
for /l %%a in (1,1,1001) do (
set file=%template%
set temp=%%a:::::::::%%a
for %%b in (!temp:~10!) do set file=!file:?=%%b!
for /l %%i in (1,1,9) do set file=!file:/:=!
set file=!file:/=0!
set file=!file::=!
echo !file!
echo.
)
pause
Last edited by obsolete on 2008-7-31 at 11:15 PM ]