一直很疑惑,
难道在批处理中使用函数就只能够在本bat中使用吗?
不可以像Shell Script里面的.或source导入一样重用,
或者至少可以call lib.bat func args
这样使用吧?
请高手指点,谢谢。
难道在批处理中使用函数就只能够在本bat中使用吗?
不可以像Shell Script里面的.或source导入一样重用,
或者至少可以call lib.bat func args
这样使用吧?
请高手指点,谢谢。
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
call 2.bat call :a
pause
@echo off
%*
goto :eof
:a
echo aaaaaaaaa
goto :eof
:b
echo bbbbbbbbb
goto :eof
| 评分人 | 分数 | 时间 |
|---|---|---|
| leson | +1 | 2008-09-15 15:18 |
@echo off
:: main entry
set "func=%~1"
shift
goto %func%
goto:EOF
:: functions definitions show below
:bannerPingPong varref -- moves text in varref one step left or right and updates title
:: -- varref - variable name with banner text, format: "Banner Text------"
SETLOCAL ENABLEDELAYEDEXPANSION
set s=!%~1: =-!
if "!s:~-1!" NEQ "-" if "!s:~-1!" NEQ "+" set s=!s!--------
set d=!s:~-1!
if "!s:~0,1!" NEQ "-" set d=+
if "!s:~-2,1!" NEQ "-" set d=-
if "!d!"=="+" (set s=-!s:~0,-2!+) ELSE (set s=!s:~1,-1!--)
TITLE !s!
(ENDLOCAL & REM RETURN VALUES
IF "%~1" NEQ "" SET %~1=%s%
)
goto:EOF
@echo off
set "text=hi -"
for /l %%C in (1,1,15) do (
call func_lib.bat :bannerPingPong text
call echo.'%%text%%'
)