Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

loops - Batch variables dont give promt to set

I'm brand new to batch file scripting, so this is going to make me appear stupid, but my variables in my test are not working.

Here is the cmd script:

@echo off
cls
: bruh
echo welcome to the shop, what would you like?
pause
set p/ grapes=
cls
echo oh so you want %grapes%?
pause
echo you have bought %grapes%
pause
cls 
goto bruh

Whenever I get to the variable, it just says press any key to continue.

Does anyone know how to fix this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

your set command was incorrect. its set /p not set p/.here's a working code

@echo off
cls
: bruh
set input=
set /p input=echo welcome to the shop, what would you like?
cls
echo oh so you want %input%?
pause
echo you have bought %input%
pause
cls 
goto bruh

Thanks to @Compo he reminded me to clear content of %input%


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...