Je ne sais pas comment formuler cette question pour que vous compreniez, mais soyez indulgents avec moi. Voici mon code:

set var1=yes no ok get out of here exit quit

echo Do you want to start?

set /p options=Your Input:

if "%Options%" (This is what I need help with)

Comparez l'entrée utilisateur à var1 et si elle est vraie, passez à la question suivante Même si l'entrée utilisateur «Go start», elle correspondra soit Go soit Start à var1. Puisque Go ne figure pas dans la liste, il essaierait de faire correspondre Start avec var1. Et si trouvé, passez à la question suivante. J'espère que cela a du sens

-2
John Hang 31 déc. 2015 à 10:33

2 réponses

Meilleure réponse
for %%a in (%options%) do for %%b in (%var1%) do if /i "%%a"=="%%b" goto nextq
:not_found
response "%options%" is not implemented
pause

Preuve de code:

c:\106x>q34542866
Do you want to start?
Your Input:go
User input was "go"
response "go" is not implemented

c:\106x>q34542866
Do you want to start?
Your Input:no
User input was "no"
response "no" found

c:\106x>q34542866
Do you want to start?
Your Input:exit
User input was "exit"
response "exit" found

c:\106x>q34542866
Do you want to start?
Your Input:go start
User input was "go start"
response "go start" is not implemented

c:\106x>q34542866
Do you want to start?
Your Input:I do want to start, yes please
User input was "I do want to start, yes please"
response "I do want to start, yes please" found

Avec code:

set var1=yes no ok get out of here exit quit
echo Do you want to start?
set /p options=Your Input:

ECHO User input was "%options%"

for %%a in (%options%) do for %%b in (%var1%) do if /i "%%a"=="%%b" goto nextq
:not_found
ECHO response "%options%" is not implemented

GOTO :EOF

:nextq
ECHO response "%options%" found

GOTO :EOF
1
Magoo 31 déc. 2015 à 08:57
@echo off
setlocal EnableDelayedExpansion

set "var1= yes no ok get out of here exit quit "
echo Do you want to start?
set /p options=Your Input:

for %%a in (%options%) do if "!var1: %%a =!" neq "%var1%" goto nextquestion
echo Word not found...
goto :EOF

:nextquestion
echo Word found
0
Aacini 31 déc. 2015 à 11:39