Batch Reads Text

HandyAndy February 7, 2009 at 13:51:58
Specs: Windows XP
Hello,

Im trying to make a batch as follows:

I want the file to open and scroll out whatever I typed in the batch file instead of just showing all the text at once.

Basically animate my text as if you were typing it as you read it.

Thanks for your help.
HandyAndy


See More: Batch Reads Text

Report •


#1
February 7, 2009 at 15:14:33
Here's my attempt.

@ECHO OFF
setlocal
set fn=%~f1
if not exist "%fn%" set /p fn=Plese type in a file name, you may also need to enter the full path if the file isn't in the same directory:  
cls
for /f "delims=" %%a in ('type "%fn%"^|find /n /v ""') do (
set line="%%a"
SETLOCAL ENABLEDELAYEDEXPANSION
set lb=
call :strip int ern
:strip
if "%~1%~2"=="intern" (
if "!line:~0,1!"=="]" (
set line="!line:~1!
goto :eof
) else (
set line=!line:~1!
goto strip
))
if !line!=="" set lb=1
set line=!line:~1,-1!
call :loop int ern
:loop
if "%~1%~2"=="intern" (
if defined line (
set /p =!line:~0,1!<nul
>nul ping 0.0.0.0 -n 1
set line=!line:~1!
goto loop
) else (
if defined lb (
>nul ping 0.0.0.0 -n 1
echo.
))
echo.
goto :eof
)
endlocal
)
pause
endlocal


Report •

#2
February 9, 2009 at 03:37:29
I have made a little change to the above script to allow files that contain "=" to be displayed properly to screen using a control character(^h - hex 08) to work around set /p's apparent inability of "prompt string" to begin with =. Doesn't work properly to file though, half full of control characters that don't convert properly using for or type....

@ECHO OFF
setlocal
set fn=%~f1
if not exist "%fn%" set /p fn=Plese type in a file name, you may also need to enter the full path if the file isn't in the same directory:  
cls
for /f "delims=" %%a in ('type "%fn%"^|find /n /v ""') do (
set line="%%a"
SETLOCAL ENABLEDELAYEDEXPANSION
set lb=
call :strip int ern
:strip
if "%~1%~2"=="intern" (
if "!line:~0,1!"=="]" (
set line="!line:~1!
goto :eof
) else (
set line=!line:~1!
goto strip
))
if !line!=="" set lb=1
set line=!line:~1,-1!
call :loop int ern
:loop
if "%~1%~2"=="intern" (
if defined line (
set /p = !line:~0,1!<nul
>nul ping 0.0.0.0 -n 1
set line=!line:~1!
goto loop
) else (
if defined lb (
>nul ping 0.0.0.0 -n 1
echo.
))
echo.
goto :eof
)
endlocal
)
pause
endlocal

In case anyone is interested it is possible to sc stop beep then use  (^G -hex 07) without the leading character to output to a text file, sc start beep the parse the text file using for /f and !var:=!, unless of course the file is ment to contain .


Report •

Related Solutions


Ask Question