Moving colored text (marquee sign), tips?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cornbeetle
Posts: 31
Joined: 23 Nov 2015 09:34

Moving colored text (marquee sign), tips?

#1 Post by Cornbeetle » 15 Dec 2016 09:54

Here's the code I have for a moving marquee-style banner, using the showColor routine found on Stackoverflow (credit: Jeb)
Does anyone have an idea how I can reduce this code into some type of loop, rather than block after block of the same code...

Code: Select all

@echo off
color 07
setlocal EnableDelayedExpansion
call :configColor

call :applyColor 01 "  "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "   "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "    "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "     "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "      "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "       "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "        "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "         "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "          "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "           "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "            "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "             "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "              "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

call :applyColor 01 "               "
call :applyColor 17 "  HELLO WORLD  "
pathping -q 1 -p 100 localhost >nul
cls

PAUSE

:applyColor
set "param=^%~2" !
set "param=!param:"=\"!"
findstr /p /A:%1 "." "!param!\..\X" nul
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
exit /b

:configColor
:: Commands for color show config
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  set "DEL=%%a"
)
<nul > X set /p ".=."
exit /b


Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Moving colored text (marquee sign), tips?

#2 Post by Compo » 15 Dec 2016 10:54

Clue:

Code: Select all

FOR /L %%A IN (2,1,15) DO …

Cornbeetle
Posts: 31
Joined: 23 Nov 2015 09:34

Re: Moving colored text (marquee sign), tips?

#3 Post by Cornbeetle » 15 Dec 2016 12:48

Compo wrote:Clue:

Code: Select all

FOR /L %%A IN (2,1,15) DO …


But how would I change the spacing distance in between the quotes for each loop?

Code: Select all

call :applyColor 01 "            "

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Moving colored text (marquee sign), tips?

#4 Post by Compo » 15 Dec 2016 14:21

You could have at least shown that you'd made an attempt at something using the clue I gave you, which isn't incidentally the only way to do it.

Code: Select all

SetLocal EnableDelayedExpansion
Set "_= "
For /L %%A In (2,1,15) Do (Set "_=!_! "
   call :applyColor 01 "!_!"
   call :applyColor 17 "  HELLO WORLD  "
   pathping -q 1 -p 100 localhost >nul
   cls)

PAUSE

:applyColor

Cornbeetle
Posts: 31
Joined: 23 Nov 2015 09:34

Re: Moving colored text (marquee sign), tips?

#5 Post by Cornbeetle » 15 Dec 2016 15:56

Duh..I didn't think about making the variable a 'space'...thanks!

Compo wrote:You could have at least shown that you'd made an attempt at something using the clue I gave you, which isn't incidentally the only way to do it.

Code: Select all

SetLocal EnableDelayedExpansion
Set "_= "
For /L %%A In (2,1,15) Do (Set "_=!_! "
   call :applyColor 01 "!_!"
   call :applyColor 17 "  HELLO WORLD  "
   pathping -q 1 -p 100 localhost >nul
   cls)

PAUSE

:applyColor

Post Reply