有运行我的批处理文件中的困难时期。
我相信这与我的if语句有关,它不会通过。
我总是以“如果在这个时候意外”结束。
请任何帮助非常感谢Windows批处理标签循环
:firstNumber
set /p "firstNum = Enter the first number (other than 22) "
if "%firstNum%"=="22" (
goto :end
) else (
goto :secondNumber
)
:secondNumber
set /p "secondNum = Enter the second number (other than 22 and 0) "
if "%secondNum%"=="22" (
goto :end
) if "%secondNum%"=="0" (
goto :errorNumber
) else (
goto :command
)
:errorNumber
echo You cannot divide by 0
goto :secondNumber
:command
set /a quotient=%firstNum%/%secondNum%
echo "%firstNum% divided by %secondNum% = !quotient!
:end
我想,以限定的情况下的默认用户只需按下_enter_,如'设置“firstNum = 0”'和'设置“secondNum = 0”''之前设置/ P'插入标准'set'命令, 分别;那么我会从'if'比较中删除引号,并用'EQU'替换运算符'=='以便进行数字比较而不是字符串比较(如'if%secondNum%EQU 0');最后,我会缩进一对括号中的所有命令以提高可读性... – aschipfl