How to use the echo command after a set /p command
Asked Answered
A

3

5

I wanted to make this script work somehow, but i find that after you use

set /p variable= whater you want here

If you use the echo command after it, its hidden or something because it wont come up...

@echo off 
cls 
color A 
:MAIN 
cls 
echo. 
echo. 
echo ================================= 
echo. set /p var= what is your name? 
:: DOES NOT SHOW UP (STARTING HERE) 
echo. 
echo ================================= 
:: DOES NOT SHOW UP (ENDING HERE) 
set /p answer= so your name is %var%? 
IF %answer%== yes echo thats an amazing name! 
IF %answer%== no goto MAIN 

The part thats surrounded by the remarks doesnt want to show up for some reason... any ideas?

Aufmann answered 1/12, 2010 at 3:30 Comment(0)
N
5

If I'm understanding what you are trying to do, this is the code you need:

@echo off  
cls  
color A  
:MAIN  
cls  
echo =================================  
echo what is your name?  
echo =================================  
set /p var=
set /p answer= so your name is %var%?  
IF [%answer%] == [yes] echo thats an amazing name!  
IF [%answer%] == [no] goto MAIN  
pause
Nubbin answered 1/12, 2010 at 11:45 Comment(0)
C
3

Because the processor will wait for the user input after printing what is your name? (due to the /p), you will not get the next line of ========etc. until enter is pressed.

Codpiece answered 1/12, 2010 at 3:42 Comment(0)
M
1

It shows up for me, I get

=================================
 set /p var= what is your name?

=================================
 so your name is ? Andy

Which is what I would expect, what are you expecting?

Multicellular answered 1/12, 2010 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.