标题: [文本处理] 批处理动态逐字显示一副对联中call的解释 [打印本页]
作者: baiyuheitu 时间: 2009-4-30 13:58 标题: 批处理动态逐字显示一副对联中call的解释
这段代码应如何解释,尤其是设计call的部分,搜索解释也没找到,最头疼的是程序中有的地方的%多的看的我晕头转向!
-
- @echo off
- set str=四四四四ABCDEFG1234567
- set "line= "
- set "sleep=ping 127.1 -n 2 >nul"
- echo.
- call :split 4 7 col
- call :split 11 7 col "cls&echo."
- call :split 0 4 line "cls"
- pause>nul
- goto :eof
-
- :split
- set /a _tmp1=%1+%2-1,count=0
-
- for /l %%a in (%1,1,%_tmp1%) do (
- set /a count+=1
- %~4
-
- if %~3 == col (
- call call set %3%%count%%=%%%%%3%%count%%%%%%%line%%%str:~%%a,1%%
- if %~1 == 4 (
- call :cout %%count%% %%count%% %~3
- ) else (
- call :cout 1 7 %~3
- )
- ) else (
- call set %3=%%%3%% %%str:~%%a,1%%
- call :cout 1 7 col "echo %%%3%%"
- )
-
- %sleep%
- )
- goto :eof
-
-
- :cout
- %~4
- for /l %%i in (%1,1,%2) do (
- call echo.%%%3%%i%%
- )
- goto :eof
-
-
-
-
-
-
-
-
-
-
-
-
复制代码
作者: everest79 时间: 2009-4-30 20:20
嘿嘿看看这些
作者: suneast 时间: 2009-4-30 20:47
楼上的给个解析吧,我也是刚来的不懂啊?
那些教程虽然有用,但是在我找到答案的时候。。。
谁来帮忙?
作者: everest79 时间: 2009-4-30 20:58
这样可能比较清楚,具体的其实可以打开回显或插入set&pause来查看变量变化- @echo off
- setlocal enabledelayedexpansion
- set str=四四四四ABCDEFG1234567
- set "line= "
- set "sleep=ping 127.1 -n 1 >nul"
- echo.
- call :split 4 7 col
- ::set&pause
- call :split 11 7 col "cls&echo."
- call :split 0 4 line "cls"
- pause>nul
- goto :eof
-
- :split
- set /a _tmp1=%1+%2-1,count=0
-
- for /l %%a in (%1,1,%_tmp1%) do (
- set /a count+=1
- %~4
-
- if %~3 == col (
- call set %3!count!=%%%3!count!%%%line%!str:~%%a,1!
- if %~1 == 4 (
- call :cout !count! !count! %~3
- ) else (
- call :cout 1 7 %~3
- )
- ) else (
- set %3=!%3! !str:~%%a,1!
- call :cout 1 7 col "echo !%3!"
- )
-
- %sleep%
- )
- goto :eof
-
-
- :cout
- %~4
- for /l %%i in (%1,1,%2) do (
- call echo.!%3%%i!
- )
- goto :eof
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |