我转到重定向不工作,但与之呼应的作品 [英] my goto redirect is not working but works with echo

查看:138
本文介绍了我转到重定向不工作,但与之呼应的作品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 关闭@echo
:启动1
集/ P输入=动作:
FOR / F令牌= 1-2 delims =%%一中(%输入%),做(
后藤:%%〜一_ %%〜B> NUL 2 - ;&放大器; 1 ||转到启动1

如果我把| |回应您的输入无法识别它的工作原理,但转到启动1崩溃脚本

 :explore_room
@echo房探讨
转到启动1
暂停
:examine_door
@echo门检查
暂停
:examine_wall
@echo墙检查
暂停


解决方案

 关闭@echo
:启动1
集/ P输入=动作:
拨打:%输入:= _%2 - ; NUL
如果错误级别1回显您的输入无法识别
转到启动1
:explore_room
@echo房探讨
暂停
出口/ B 0:examine_door
回音门检查
暂停
出口/ B 0:examine_wall
回音壁检查
暂停
出口/ B 0

例如:

 行动:检查门
检查门
presione UNA tecla第continuar。 。 。
动作:探索大厅
您的输入无法识别
动作:探索室
房间探讨
presione UNA tecla第continuar。 。 。
¿Desea terminar EL特拉瓦霍POR嘉泽端子工业股份有限公司(S / N)?小号

@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
)    

if I put "| | echo your input is not recognized" it works, but the "goto start1" crashes the script

: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

这篇关于我转到重定向不工作,但与之呼应的作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆