The following is a quote from lifeng5115 at 2003-8-8 11:16:52:
I want DOS to prompt me to input a string:
After I enter characters and press Enter, the characters entered will be saved in a file.
like this the screen displays
please in put string:
I enter
ddddd
After that, I can get ddddd in some .txt file
Then ask for confirmation input:
please put string again
If this input is different from the first one, then report an error.
Thanks, I sincerely ask everyone to help
:: Get user input - includes error check
@echo off
set secondpass=
echo e100'set input='>%temp%.\temp.dat
echo w>>%temp%.\temp.dat
echo q>>%temp%.\temp.dat
:input
echo.
if not %secondpass%.==1. echo Type in input
if %secondpass%.==1. echo Type in input again
echo.>%temp%.\temp.bat
FC con nul /lb1 /n |FIND.exe "1:" >> %temp%.\temp.bat
:: Error checking begins here
FIND "|" %temp%.\temp.bat > nul
if not errorlevel=1 goto error
FIND "=" %temp%.\temp.bat > nul
if not errorlevel=1 goto error
FIND " nul
if not errorlevel=1 goto error
FIND ">" %temp%.\temp.bat > nul
if not errorlevel=1 goto error
:: Error checking end
DEBUG %temp%.\temp.bat nul
call %temp%.\temp.bat
if exist %temp%.\temp.?at del %temp%.\temp.?at
rem echo INPUT=%INPUT%
goto EOF
:error
echo.
echo @PROMPT Error - invalid characters: $Q $L $G $B> %temp%.\temp.bat
%comspec% /c %temp%.\temp.bat |FIND.exe "Error:"
goto input
:eof
if not %secondpass%.=1. echo %INPUT%>1st.txt
if not %secondpass%.=1. set secondpass=1
if %secondpass%.=1. type 1st.txt|find "%INPUT%">NUL
if errorlevel 1 goto notmatch
goto end
:notmatch
ECHO The input does not match!
goto end
:end