Page 1 of 1

Batch Animated Text

Posted: 26 Mar 2015 07:43
by Flaming_PC
How do i do animated text like the following:
frame 1) H
frame 2) HE
frame 3) HEL
frame 4) HELL
frame 5) HELLO
but yet, i dont want to do:
echo H
ping localhost -n 1 >nul
cls
echo HE
because it takes up a lot of space and time

Thanks in Advanced :lol:

Re: Batch Animated Text

Posted: 26 Mar 2015 17:55
by aGerman

Code: Select all

@echo off &setlocal
:: create a backspace character
for /f %%i in ('"prompt $H &for %%b in (1) do rem"') do set "bs=%%i"

:: animate the string
for %%i in (
  H E L L O "," " " W O R L D !
) do (<nul set /p "=.%bs%%%~i" & >nul ping -n 1 localhost)

:: add a line break
echo(

pause

As you can see the characters are separated by spaces. Token separators (such as spaces or commas) have to be enclosed into quotation marks.

Regards
aGerman

Re: Batch Animated Text

Posted: 26 Mar 2015 18:24
by foxidrive
This is a simple method to solve your question:

Code: Select all

@echo off
for %%a in (H HE HEL HELL HELLO) do (
cls
echo %%a
ping -n 2 "">nul
)
pause

Re: Batch Animated Text

Posted: 17 Apr 2015 20:37
by carlsomo
SpinSpell.bat ["Message goes here"] [spincount] [spindelay]

Code: Select all

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "$BS=%%a"
SET /A SpinCount=7,MaxSpinCount=30,Spin_Delay=4,ctr=0
SET "_MSG=ÛÛÛÛÛÛÛÛÛÛÛÛÛ"
IF NOT [%1]==[] (
  SET "_MSG=%~1"
  if defined %~1 set "_msg=!%~1!"
)
IF NOT [%2]==[] SET /A SpinCount=%~2
IF NOT [%3]==[] SET /A Spin_Delay=%~3
IF %SpinCount% GTR %MaxSpinCount% SET /A SpinCount=MaxSpinCount
SET "Spinner=³/Ä\"
call :strln _msg slen
set/a slen-=1
FOR /L %%a in (0 1 %slen%) DO (
  FOR /L %%A IN (1,1,%SpinCount%) DO (
    CALL :Delay %Spin_Delay%
    <nul CALL SET/P="%$BS%%%Spinner:~!ctr!,1%%"
    SET /A CTR=%%A %% 4
  )
  <nul set/p="%$BS%!_MSG:~%%a,1! "
)
ENDLOCAL & EXIT /B

:Strln
( SetLocal
  set "str=A!%~1!"
  set "len=0"
  for /L %%A in (12,-1,0) do (
    set /a "len|=1<<%%A"
    for %%B in (!len!) do if "!str:~%%B,1!"=="" set /a "len&=~1<<%%A"
  )
)
EndLocal&( REM RETURN VALUES
  if "%~2" NEQ "" set/a %~2=%len%
)&exit /b %len%

:Delay centiseconds
setlocal
set/a delay=%~1
for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "time1=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100
:wait
  for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "time2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=time2-time1"
  if %tDiff% lss 0 set /a tDiff+=24*60*60*100
  if /i %tDiff% geq %delay% endlocal&goto :eof
goto :wait

Re: Batch Animated Text

Posted: 17 Apr 2015 21:55
by carlos

Code: Select all

@Echo Off
SetLocal EnableDelayedExpansion
Set "txt=HELLO"
For /L %%# in (0,1,4) Do (Set /P "=!txt:~%%#,1!" <Nul
Ping.exe -l 0 -n 1 -w 500 1.0.0.0 >nul
)
Echo(
PAUSE
Goto :Eof


Re: Batch Animated Text

Posted: 18 Apr 2015 02:50
by Yury

Code: Select all

@powershell "gc '%~f0'|select -skip 1|%%{$_.getenumerator()|%%{write-host $_ -nonewline -foregroundcolor yellow -backgroundcolor darkgreen;sleep -milliseconds 100};''}"& pause>nul& exit/b


Hello, Flaming_PC!

Here you can place
any large text.

Re: Batch Animated Text

Posted: 18 Apr 2015 07:22
by AiroNG
carlsomo wrote:SpinSpell.bat ["Message goes here"] [spincount] [spindelay]

Code: Select all

*snip*
:wait
  set timen=%time: =%
  if /i %timen% geq %time2% goto :end
goto :wait
*snip*


shouldn't that be:

Code: Select all

set timen=%time:~0,8% 
?

[/code]
Because otherwise i get a Syntax error message:

Code: Select all

 D:\set timen=15:15:02,59
"59" kann syntaktisch an dieser Stelle nicht verarbeitet werden.


but even without the error it wont work. it shows me literally nothing.
Is there an additional error in the script or am i just to stupid to use it? :mrgreen:

Re: Batch Animated Text

Posted: 18 Apr 2015 11:14
by Yury

Code: Select all

@for /f %%i in ('^<"%~f0" find/c /v ""') do @(
  for /f "delims=:" %%j in ('findstr/enc:"& :::::" "%~f0"') do @<"%~f0" (
   for /f %%k in ('forfiles /m "%~nx0" /c "cmd /c echo 0x08"') do @(
    for /l %%l in (1 1 %%i) do @(
     set x=& set/p x=&if %%l gtr %%j (
      if not defined x (echo.) else (
       if defined * (echo.) else (set *=*)
       for /f "delims=" %%m in ('cmd/u/v/c echo.!x!^| more^| findstr/n "^"') do @set y=%%m& (
        for /f "delims=" %%n in ('cmd/v/c echo."!y:*:=!"') do @<nul (
         if %%n neq " " (if %%n neq "=" (set/p=%%n) else (set/p=.%%k=)) else (set/p=.%%k %)
         >nul ping -n 1 -w 100 ""
        )
       )
      )
     )
    )
   )
  )
 )
@pause>nul& exit/b& :::::
     

Hello, Flaming_PC!

Here you can place
any large English text.

"="="="="="="="="=

Re: Batch Animated Text

Posted: 18 Apr 2015 12:27
by carlsomo
AiroNG

My time is format h:mm:ss.hs yours has a comma h:mm:ss,hs
so add a comma to the delimeters in this for loop in the delay routine:

Code: Select all

for /f "tokens=1-4 delims=:.," %%a in ("%time1%") do (


Then it should work. I have only tested on Win7.

Re: Batch Animated Text

Posted: 18 Apr 2015 17:36
by AiroNG
carlsomo wrote:AiroNG

My time is format h:mm:ss.hs yours has a comma h:mm:ss,hs
so add a comma to the delimeters in this for loop in the delay routine:

Code: Select all

for /f "tokens=1-4 delims=:.," %%a in ("%time1%") do (


Then it should work. I have only tested on Win7.



So I am stupid then :)
Ok, i will test it after i get back home. Thank you.

Re: Batch Animated Text

Posted: 18 Apr 2015 21:25
by carlsomo
AiroNG

I apologize for not recognizing the variables in DOS related to regional and language settings. I am usually pretty happy getting something to work in one version, mine. :wink:

Carl