协助嵌套if语句

一定要有人

我是stackOverflow的新手。我有个问题。为什么我的代码不起作用...它嵌套在if语句中,那应该起作用...我很困惑。您应该有钱,房屋(类型1至3)和电话。电话是问题。callLine用于告诉每次调用callText时将显示哪一行。每次在Calling2中被调用时,它自身都会加1。只要达到某个数字,它就会将callText(显示的文本)更改为其他内容。但是,对于callWho变量(工作或家庭),也需要对其进行检查。这里是:

@ echo off
set money=10000
set house=1
set item=Phone
set /a callLine=0
setlocal enabledelayedexpansion
echo Hello there! I am Joe, and I am the mayor of Redcrest Town.
pause
cls
echo I'm so happy to see another resident move into the Redcrest Town.
echo So, will you do me a favour and tell me your name?
set /p Name=
cls
echo Well then, %name%! Welcome!
pause
cls
echo I hope you have a great time here. You have 10,000 dollars, and a small house.
echo Please enjoy your time here!
pause
cls
:UsePhone
echo Money: %money%
echo.
echo You are using your phone. This will cost money, each time you call.
echo.
echo.
echo  __i         [CONTACT LIST]
echo ^|---^|      [1: HOME     ] 
echo ^|[_]^|      [2: WORK     ]
echo ^|:::^|    
echo ^|:::^|    
echo `\   \   
echo   \_=_\
set /p callWho=Select Number:
if %callWho% == 2 goto Calling
echo %callText%
pause
:Calling
cls
echo Calling......
ping localhost -n 4 >nul
:Calling2
if callLine == 0 if %callWho% == 2 set callText="Hello? Is this %name%?"
if callLine == 1 if %callWho% == 2 set callText="Oh hello! It's really nice to talk to you again."
if callLine == 2 if %callWho% == 2 set callText="Well, I will see you soon, %name%! Bye!"
if callLine == 3 if %callWho% == 2 set callText="END"
set /a callLine = callLine + 1
cls
echo  __i         
echo ^|---^|       
echo ^|[_]^|   PHONE: %callText%   
echo ^|:::^|    
echo ^|:::^|    
echo `\   \   
echo   \_=_\
ping localhost -n 5 >nul
if %callText% == "END" goto UsePhone
goto Calling2

我不断崩溃:。这时真是出乎意料。

章鱼

您忘记了附近的%% callLine

:Calling2
if %callLine% == 0 if %callWho% == 2 set callText="Hello? Is this %name%?"
if %callLine% == 1 if %callWho% == 2 set callText="Oh hello! It's really nice to talk to you again."
if %callLine% == 2 if %callWho% == 2 set callText="Well, I will see you soon,     %name%! Bye!"
if %callLine% == 3 if %callWho% == 2 set callText="END"
set /a callLine = callLine + 1

使用if语句测试变量时,变量必须包含在%%中

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章