如果我想在未填充变量favnum
时回显警告,我该怎么办?
我已经尝试过了:
echo What's your favorite color?
echo.
set /p favnum=">"
if not defined favnum(
goto nope
)
答案 0 :(得分:8)
在favnum
和(
答案 1 :(得分:4)
如前所述,您错过了favnum
和(
您也可以使用
echo What's your favorite color?
echo.
set /p favnum=">"
if "%favnum%"=="" (
goto nope
)
或将放在一行上的变量
echo What's your favorite color?
echo.
set /p favnum=">"
if "%favnum%"=="" goto nope
这将成为你的榜样
echo What's your favorite color?
echo.
set /p favnum=">"
if not defined favnum goto nope