4

文字列が MRSVANDERTRAMP.txt に含まれているかどうかに関係なく、このバッチ ファイルのこの部分に入力されたものはすべて、自動的に :yes に移動します。

:enterverb
set /p id=Enter Verb: 

findstr /m %id% MRSVANDERTRAMP.txt
if %errorlevel%==0 (
goto :yes 
) else (
goto :no
)

:no
echo Verb does not take etre in the Perfect Tense. 
pause
goto :option0

:yes
echo Verb is a MRSVANDERTRAMP verb and takes etre in the Perfect Tense.
pause
4

4 に答える 4

1

私はそれをテストするために同様のコードを思いつきましたが、うまくいきました。

@echo off
@title TEST

:main
set /p word=Write a word: 

findstr /M %word% words.txt

if "%errorlevel%" == "0" ( echo FOUND ) else ( echo NOT FOUND )
pause>nul
cls && goto main




IF文に問題があるのか​​もしれません..使ってみてください.

if "%errorlevel%" == "0" 

代わりに

if %errorlevel%==0
于 2013-09-10T20:25:30.190 に答える
0

男はこれを試してみてください

動詞

set /p id=Enter Verb: 
findstr /m %id% MRSVANDERTRAMP.txt

set a=0

if %errorlevel%== %a% (
goto :yes 
) else (
goto :no
)

:no
echo Verb does not take etre in the Perfect Tense. 
pause
goto :option0

:yes
echo Verb is a MRSVANDERTRAMP verb and takes etre in the Perfect Tense.
于 2014-11-22T16:56:44.780 に答える
0

これはうまくいきます。"%id%"ただし、いくつかの有害な文字から保護するために、示されているように二重引用符で囲むことをお勧めします。

@echo off

echo one>MRSVANDERTRAMP.txt
echo two>>MRSVANDERTRAMP.txt


:enterverb
set /p id=Enter Verb: 

findstr /m %id% MRSVANDERTRAMP.txt
if %errorlevel%==0 (
goto :yes 
) else (
goto :no
)

:no
echo Verb does not take etre in the Perfect Tense. 
pause
goto :option0

:yes
echo Verb is a MRSVANDERTRAMP verb and takes etre in the Perfect Tense.
pause

:option0
echo done
pause
于 2013-09-10T22:03:33.840 に答える