gpt4 book ai didi

if-statement - 在 If 命令之后设置命令

转载 作者:行者123 更新时间:2023-12-04 04:50:26 25 4
gpt4 key购买 nike

尝试制作测验 show.bat 文件并遇到 If-Set 编码问题:

:10    
echo @: (Press any key to continue)
pause >nul
cls
echo Bonus Question 1:
echo Translate the letters in CAPS.
echo @: Copy the sentence and translate the words in CAPITALS.
echo Il nome di mia ZIA e Gabriella e il nome di mio ZIO e Nick.
echo @: Careful, you only get 3 goes!
echo @: now you try!
set /p BonusAnswer1=">"
set /p BonusAnswer1=">"
if "%BonusAnswer1%"=="Il nome di mia aunty Gabriella e il nome di mio uncle Nick. echo well done! &goto:11
if "%BonusAnswer1%"=="Hint" echo @: Copy the sentence and translate ZIA and ZIO. Only put a capital for Il, Gabriella and Nick. &goto:10

这是我遇到问题的地方:
if "%Bonus1Tries%"=="3" set Bonus1Tries=2 &echo you only have %Bonus1Tries% left!

该编码中唯一不起作用的部分是它说:
you only have 3 tries left!

代替
you only have 2 tries left!

意思就是

设置 Bonus1Tries=2

不工作。
你能帮忙吗,提前谢谢你! -批处理人

最佳答案

在你需要的代码块内delayed expansion ,或者您拆分命令(如果可能):

if "%Bonus1Tries%"=="3" set "Bonus1Tries=2"
if "%Bonus1Tries%"=="2" echo you only have %Bonus1Tries% left!

关于if-statement - 在 If 命令之后设置命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17895389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com