If receives x, goto :x?
Moderator: DosItHelp
If receives x, goto :x?
Is there a command like this? Where if, the batch requests some text, and if it matches the text it requested, then it proceeds?
Re: If receives x, goto :x?
Seems you have to learn the basics.
Have a lokk to the Command Index.
Of course, there is a way to compare an user input.
Or not that "Spaghetti-Code-Like"
Regards
aGerman
Have a lokk to the Command Index.
Of course, there is a way to compare an user input.
Code: Select all
@echo off &setlocal
set /p "input=Enter a or b: "
if /i "%input%"=="a" goto a
if /i "%input%"=="b" goto b
goto c
:a
echo you entered an "a"
goto :end
:b
echo you entered an "b"
goto :end
:c
echo you entered neither "a" nor "b""
:end
echo.
pause
Or not that "Spaghetti-Code-Like"
Code: Select all
@echo off &setlocal
set /p "input=Enter a or b: "
if /i "%input%"=="a" (call :a) else (
if /i "%input%"=="b" (call :b) else call :c
)
echo.
pause
goto :eof
:a
echo you entered an "a"
goto :eof
:b
echo you entered an "b"
goto :eof
:c
echo you entered neither "a" nor "b""
goto :eof
Regards
aGerman
Re: If receives x, goto :x?
Thank you for that command index link, it's very helpful. I was looking for something like that on the site.
But can I have it so that the input has more than one letter in it? That's what I was looking for.
But can I have it so that the input has more than one letter in it? That's what I was looking for.
Re: If receives x, goto :x?
It's exactly the same.
Just pay attention that a label will be valid until the first space.
:abc 1 is the same like :abc 2.
Regards
aGerman
Just pay attention that a label will be valid until the first space.
:abc 1 is the same like :abc 2.
Regards
aGerman
Re: If receives x, goto :x?
Ah, okay, thank you very much, that's very helpful!
Re: If receives x, goto :x?
Oh yeah, and one more thing:
Can I hide the 'enter a or b' text?
Edit:
Nevermind, I found out how!
Can I hide the 'enter a or b' text?
Edit:
Nevermind, I found out how!