我的脚本需要帮助。所有的东西都在不断下降,而不是去做。你能帮忙吗?
@ECHO OFF
goto joshua
:joshua
Echo Hello my name is Joshua.
echo What is yours?
set /p name=
cls
Echo Hello %name%.
cls
Echo How are you?
set /p feeling=
cls
echo Is this good?
echo Im sorry I am still learning human feelings.
set /p humanfeelings=Yes/No
if %humanfeelings%==Yes goto Good
if %humanfeelings%==No goto Bad
cls
:Good
Echo Well that is pleasent.
Echo Would you like to play a game %name%?
set /p answer=Yes/No
if %answer%==Yes goto startmenu
if %answer%== No goto quit
cls
:Bad
echo That is not good.
echo Would you like to play a game %name%?
set /p answera=Yes/No
if %answera%==Yes goto startmenu
if %answera%== No goto later
cls
:startmenu
start menu.bat
cls
:later
Echo That is fine %name%, maybe later
pause
exit
答案 0 :(得分:2)
包含行号的原始代码:
1 : @ECHO OFF
2 : goto joshua
3 : :joshua
4 : Echo Hello my name is Joshua.
5 : echo What is yours?
6 : set /p name=
7 : cls
8 : Echo Hello %name%.
9 : cls
10: Echo How are you?
11: set /p feeling=
12: cls
13: echo Is this good?
14: echo Im sorry I am still learning human feelings.
15: set /p humanfeelings=Yes/No
16: if %humanfeelings%==Yes goto Good
17: if %humanfeelings%==No goto Bad
18: cls
19: :Good
20: Echo Well that is pleasent.
21: Echo Would you like to play a game %name%?
22: set /p answer=Yes/No
23: if %answer%==Yes goto startmenu
24: if %answer%== No goto quit
25: cls
26: :Bad
27: echo That is not good.
28: echo Would you like to play a game %name%?
29: set /p answera=Yes/No
30: if %answera%==Yes goto startmenu
31: if %answera%== No goto later
32: cls
33: :startmenu
34: start menu.bat
35: cls
36: :later
37: Echo That is fine %name%, maybe later
38: pause
39: exit
goto joshua
不必要,因为约书亚在下一行。 cls
删除前面的回音(隐藏Hello %name%.
)hell
no!!!
或yes, i am.
)会导致语法错误我还建议将这些if语句更改为if-else,并使用不区分大小写的字符串与if /I
进行比较。尝试这些修改:
@echo off
:joshua
echo Hello. My name is Joshua.
echo What is yours?
set /p name=
cls
echo Hello, %name%.
echo How are you?
set /p feeling=
cls
echo Is this good?
echo I'm sorry. I am still learning human feelings.
set /p humanfeelings=Yes/No
if /I "%humanfeelings%"=="yes" (
goto Good
) else (
goto Bad
)
cls
:Good
echo Well that is pleasant.
goto AskPlay
:Bad
echo That is not good.
:AskPlay
echo Would you like to play a game, %name%?
set /p answera=Yes/No
if /I "%answera%"=="yes" (
goto startmenu
) else (
goto later
)
cls
:startmenu
start menu.bat
cls
:later
echo That is fine, %name%. Maybe later!
pause
exit
答案 1 :(得分:1)
好的,从我看到的错误来看,你不会在好/坏操作结束时跳到任何地方。这意味着无论您输入“是”还是“否”,都会一个接一个地执行Bad / startmenu / later块。这是你遇到的问题吗?然后再添加一些goto-s。
答案 2 :(得分:0)
您是否在响应提示时输入完整答案是或否?如果缩写为Y和N,则只存储那些初始字符。
答案 3 :(得分:0)
尝试删除这些行中单词No
之前的空格:
if %answer%== No goto quit
和
if %answera%== No goto later
像我们许多已经失去了实用性的人一样,批量翻译很老而且挑剔。 : - )