Computing.Net > Forums > Programming > Batch Reads Text

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Reads Text

Reply to Message Icon

Name: HandyAndy
Date: February 7, 2009 at 13:51:58 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: February 7, 2009 at 15:14:33 Pacific
Reply:

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


0

Response Number 2
Name: Judago
Date: February 9, 2009 at 03:37:29 Pacific
Reply:

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 .


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Reads Text

Batch [READ FROM FILE THEN ECHO ] www.computing.net/answers/programming/batch-read-from-file-then-echo-/15561.html

BATCH reading structured Text File www.computing.net/answers/programming/batch-reading-structured-text-file/14544.html

Batch read variables from text, do robocopy www.computing.net/answers/programming/batch-read-variables-from-text-do-robocopy/19307.html