|
槛之外
初级用户
 
积分 138
发帖 6
注册 2003-8-1
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
CHOICE:选择命令。这是一个DOS外部命令,但它主要用在批文件中。
CHOICE命令执行后将提示可选择的项目,这时通过一个按键来选则。
用法:CHOICE:按键表] 选择值,秒数]
其中,/C表示可选则的按键,/N表示不要显示提示信息,/S表示大小写字符敏感方式,/T表示若在批定的时间内没有选则的话,自动执行/C中定义的某个选择值。显示文本是CHOICE命令执行时的提示信息。选择结果将用ERRORLEVEL值来表示。
IF ERRORLEVEL 错误返回代号 命令
意义:如果错误返回代号大于或等于指定的代号将执行某个命令。
其中,ERRORLEVEL表示错误返回代号,很有用。对于很多DOS命令,由于执行的结果不同(如执行成功,执行失败,或被用户中断等),这些命令会返回不同的代号,以表示不同的结果。IF ERRORLEVEL命令就根据这个不同结果而产生的不同代号来执行不同的命令,通常用在某条命令之后。如IF ERRORLEVEL 1 ECHO OK!表示如果当前的错误返回代号大于或等于1时将在屏幕上显示“OK!”的字样
CHOICE: The CHOICE command. This is a DOS external command, but it is mainly used in batch files.
After the CHOICE command is executed, it will prompt for selectable items, and then select by pressing a key.
Usage: CHOICE key list] selected value, seconds]
Among them, /C means selectable keys, /N means not to display the prompt information, /S means case-sensitive mode, /T means if there is no selection within the specified time, automatically execute a certain selection value defined in /C. The prompt text is the prompt information when the CHOICE command is executed. The selection result will be represented by the ERRORLEVEL value.
IF ERRORLEVEL error return code command
Meaning: If the error return code is greater than or equal to the specified code, a certain command will be executed.
Among them, ERRORLEVEL represents the error return code, which is very useful. For many DOS commands, due to different execution results (such as successful execution, failed execution, or interrupted by the user, etc.), these commands will return different codes to indicate different results. The IF ERRORLEVEL command executes different commands according to the different codes generated by this different result, and is usually used after a certain command. For example, IF ERRORLEVEL 1 ECHO OK! means that if the current error return code is greater than or equal to 1, the words "OK!" will be displayed on the screen
|

****DOS****DOS**** |
|
2004-6-25 00:00 |
|
|
tasmzz
初级用户
 
积分 43
发帖 24
注册 2009-4-3
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
给你一段代码,你自己试试吧! choice /c:yn /t:n,5 yes, no,
Here's the translation: Give you a piece of code, you try it yourself! choice /c:yn /t:n,5 yes, no,
|
|
2009-4-4 00:41 |
|
|
SinLow
初级用户
 
积分 70
发帖 33
注册 2009-9-15
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
但是windows XP 没有这个功能了!
choice 只在:MS-DOS 6.0+,Windows 95,Windows 98,Windows Vista,Windows 7而已!!!
windows XP 是用set,
给你一段代码,你自己试试吧! !!!!
自己了解吧!!!
@ECHO off
cls
:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:hello
ECHO HELLO
goto end
:bye
ECHO BYE
goto end
:test
ECHO TEST
goto end
:end
But Windows XP doesn't have this function anymore!
choice is only available in: MS-DOS 6.0+, Windows 95, Windows 98, Windows Vista, Windows 7!!!
Windows XP uses set,
Here's a piece of code for you to try it yourself! !!!!
Just understand it yourself!!!
@ECHO off
cls
:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:hello
ECHO HELLO
goto end
:bye
ECHO BYE
goto end
:test
ECHO TEST
goto end
:end
|
|
2009-9-17 03:31 |
|
|