lxmxn's post on floor 6 has a good code, but there are the following drawbacks:
1. Because the variable delay function is enabled, it will replace the exclamation marks in the text with empty;
2. Because the ordinary for statement ignores the lines starting with semicolons, this code will not be able to extract the content of these lines;
3. The :end in the if statement cannot be called as a label by other statements, that is, when the goto end part in other statements is executed, an error will occur and it cannot jump here;
4. The quotes in SET A="%1" are redundant, because when calling, %1 has been forcibly given quotes, so the sentence if "%A%"=="" goto end will never be executed;
Based on this code, the following code is obtained:
Version 1:
@echo off
:: Replace half-width double quotes with spaces, replace equal signs with 〓, compatible with other special characters
:: Can handle lines starting with semicolons, but will ignore blank lines
:: Can be compatible with unicode - formatted text
:: Display with a blank line between each line
for /f "delims= eol=" %%i in ('type %1') do (
set "str=%%i"
call set "str=%%str:"= %%"
call :pickup
)
pause
goto :eof
:pickup
ping -n 1 127.1>nul
if "%str:~0,1%"=="=" set "str=〓%str:~1%"
set /p "=%str:~0,1%"<nul
set "str=%str:~1%"
if defined str goto pickup
echo.&echo.
goto :eof
Version 2:
@echo off
:: Several differences from version 1:
:: 1. Cannot handle unicode text
:: 2. No longer forcibly add blank lines between each line, and can display blank lines as they are
for /f "delims= eol=" %%i in ('findstr /n .* %1') do (
set "str=%%i"
call set "str=%%str:"= %%"
call set "str=%%str:*:=%%"
call :pickup
)
echo.
pause
goto :eof
:pickup
if not defined str echo.&goto :eof
if "%str:~0,1%"=="=" set "str=〓%str:~1%"
set /p "=%str:~0,1%"<nul
ping -n 1 127.1>nul
set "str=%str:~1%"
if defined str goto pickup
echo.
goto :eof
[
Last edited by namejm on 2007 - 2 - 2 at 02:06 PM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。