CMD 在一个变量中隔离一个变量
CMD Isolated a Variable Inside a Variable
if [!PointX%N%:~1,1!] == [] (echo Good) Else (echo Bad!)
代码杀死批处理文件并读取:
1!] was unexpected at this time.
完整代码是
echo off
Setlocal EnableDelayedExpansion
set /a N=1
set /a R=1
:loop
cls
echo.
echo.
echo.
echo.
if %R% EQU 1 (set /p Points=How many points do you have? ) ELSE (
echo You have %points% Total Points & echo You have %left% Points Left to Plot)
echo.
set /p PointX%N%=PointX%N% equals?
set /p PointY%N%=PointY%N% equals?
cls
if [!PointX%N%:~1,1!] == [] (echo Good) Else (echo Bad!)
pause
if %N% GEQ %R% (goto :Fin) ELSE (set /a N=%N%+1 & set /a R=2 & goto :loop)
:Fin
exit
任何帮助将不胜感激
,
是批处理中的标准分隔符 - 就像 space。
尝试使用引号 - 这将包含表达式:
if "!PointX%N%:~1,1!" equ "" (echo Good) Else (echo Bad!)
if [!PointX%N%:~1,1!] == [] (echo Good) Else (echo Bad!)
代码杀死批处理文件并读取:
1!] was unexpected at this time.
完整代码是
echo off
Setlocal EnableDelayedExpansion
set /a N=1
set /a R=1
:loop
cls
echo.
echo.
echo.
echo.
if %R% EQU 1 (set /p Points=How many points do you have? ) ELSE (
echo You have %points% Total Points & echo You have %left% Points Left to Plot)
echo.
set /p PointX%N%=PointX%N% equals?
set /p PointY%N%=PointY%N% equals?
cls
if [!PointX%N%:~1,1!] == [] (echo Good) Else (echo Bad!)
pause
if %N% GEQ %R% (goto :Fin) ELSE (set /a N=%N%+1 & set /a R=2 & goto :loop)
:Fin
exit
任何帮助将不胜感激
,
是批处理中的标准分隔符 - 就像 space。
尝试使用引号 - 这将包含表达式:
if "!PointX%N%:~1,1!" equ "" (echo Good) Else (echo Bad!)