Batch si sinon

Solved
CrashOv3r Posted messages 73 Status Membre -  
 H34DSh0T -
```html Bonjour,
I can't seem to create an if... then else condition
set /p choix=What do you want to do? (Enter the number 1, 2, or 3):
if "%choix%"=="1" (echo hello)
if "%choix%"=="2" (echo hi)
if "%choix%"=="3" (echo goodbye)
else (echo you did not enter the correct number)

When I enter the number 1, 2, or 3, I get the correct message, but below I get that the else is not recognized as a command, and if I enter the number 4 for example or anything else, I would like to get the message "you did not enter the correct number," but it always shows me the else problem.
Configuration: Windows XP Firefox 3.0.7
```

13 réponses

cs-bilou Posted messages 836 Status Membre 164
 
Otherwise, you can do it without going through the else command:

if "%choice%"=="1" echo hello
if "%choice%"=="2" echo hey
if "%choice%"=="3" echo goodbye
if %choice% GTR 3 echo you did not enter the correct number
GTR means "greater than".
Here’s a sign table that I made:
EQU - equal to
NEQ - different from
LSS - less than
LEQ - less than or equal to
GTR - greater than
GEQ - greater than or equal to

Even if the forum is already resolved, I hope I helped you.
Bilou

--
There are days when you shouldn't mess with me.
And there are days every day!
21
theo7777 Posted messages 117 Status Membre 42
 
Hello, if I type ! or ? nothing displays.
0