@echo off
:start1
set /p input=action :
for /f "tokens=1-2 delims= " %%a in ("%input%") do (
goto :%%~a_%%~b >nul 2>&1 || goto start1
)
如果我输入“| | echo your input is not recognize”它可以工作,但是“goto start1”会使脚本崩溃
:explore_room
@echo room explored
goto start1
pause
:examine_door
@echo door examined
pause
:examine_wall
@echo wall examined
pause
@echo off
:start1
set /p input=action :
call :%input: =_% 2>nul
if errorlevel 1 echo your input is not recognized
goto start1
:explore_room
@echo room explored
pause
exit /B 0
:examine_door
echo door examined
pause
exit /B 0
:examine_wall
echo wall examined
pause
exit /B 0
Example:
action : examine door
door examined
Presione una tecla para continuar . . .
action : explore hall
your input is not recognized
action : explore room
room explored
Presione una tecla para continuar . . .
¿Desea terminar el trabajo por lotes (S/N)? s
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)