函数和标签的使用

实例1:
@echo off
echo the name of the bat file is %0
echo the first vars of the bat file is %1
call:function1
call:function2
call:function2
call:function3
call:function4 robin
goto LabelEnd
echo this should not be seen
:LabelEnd
exit /b 0
:function1
echo:1
exit /b 0
:function2
echo:2
exit /b 0
:function3
echo:3
exit /b 0
:function4
echo: 函数名是%0
echo:the first vars of function is %1
exit /b 0
注意1:exit的使用。
Quits the CMD.EXE program (command interpreter) or the current batchscript.
EXIT [/B] [exitCode]
/B specifies to exit the current batch script instead of
CMD.EXE. If executed from outside a batch script, it
will quit CMD.EXE
exitCode specifies a numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number.
exitCode可以通过系统变量ERRORLEVEL取得
注意2:函数和标签的定义一样, 只是调用方式不一样。函数用call:+函数名的形式,比如call:function1。
标签使用goto LabelEnd的形式。函数还有可以 传递参数比如:call:function4 robin,而标签不行。
函数调用有 返回值,而标签没有。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值