标题: 请帮我看看这个脚本错在哪里,谢谢
[打印本页]
作者: ziver
时间: 2006-6-4 08:00
标题: 请帮我看看这个脚本错在哪里,谢谢
刚开始学习批处理
这个简单的脚本为什么每次都跳到First.
懂得的朋友帮忙解释一下,谢谢了
还有,能介绍一下choice返回值的方式吗
@echo off
:start
choice /C:FSTO /M "First,Second,Third,Out"
if errorlevel 1 goto First
if errorlevel 2 goto Second
if errorlevel 3 goto Third
if errorlevel 4 goto end
:First
echo This is the first line.
goto start
:Second
echo This is the Second line.
goto start
:Third
echo This is the Third line.
goto start
:end
echo bye!
作者: electronixtar
时间: 2006-6-4 10:49
ErrorLevel x 是指 大于 或等于 x 的情况!所以要倒着写!
if errorlevel 4 goto end
if errorlevel 3 goto Third
if errorlevel 2 goto Second
if errorlevel 1 goto First
初学者编ErrorLevel最易范的错误 ^_^
chioce的用法自己看帮助!
[
Last edited by electronixtar on 2006-6-4 at 10:51 ]
作者: 220110
时间: 2006-6-4 10:50
RE ziver :
A:使用本论坛的搜索功能比你请教,将节省你很多等候的时间,并你能见到更多的例子,了解得将更多.
B:错误码应从最高值一直往下判断.
Quote: |
if errorlevel 4 goto end
if errorlevel 3 goto Third
if errorlevel 2 goto Second
if errorlevel 1 goto First |
|
C:如果不用错误码判断,可以从用户输入的字符来判断. 见链接{1}
D:相关链接:
{1}
http://www.cn-dos.net/forum/view ... mp;highlight=choice
{2}
http://www.cn-dos.net/forum/view ... mp;highlight=choice
{3}
http://www.cn-dos.net/forum/view ... mp;highlight=choice
{4}
http://www.cn-dos.net/forum/view ... mp;highlight=choice
***************
请尽快修改贴子主题.不然willsort版主要来罚你的积分了!哈哈
建议主题:关于choice命令与errorlevel 的问题
***************
[
Last edited by 220110 on 2006-6-4 at 15:24 ]