Color function v20 patched
Posted: 03 Apr 2013 20:54
Hello. Recently I updated my code of color function. Now is more speedy. I release this version 20 as the ultimate version.
Note: 26 august 2013 this code was patched fixing a problem, anyways it have other problem with the ! for example if you try print "!windir!" it prints "C:\WINDOWS". Please, consider the version 20 as deprecated and please use version 21.
Link to version 21: http://www.dostips.com/forum/viewtopic.php?f=3&t=4881
Note: 26 august 2013 this code was patched fixing a problem, anyways it have other problem with the ! for example if you try print "!windir!" it prints "C:\WINDOWS". Please, consider the version 20 as deprecated and please use version 21.
Link to version 21: http://www.dostips.com/forum/viewtopic.php?f=3&t=4881
Code: Select all
@Echo Off
Call :Color 9 "##################" \n
Call :Color F ""
Call :Color A "Final"
Call :Color B " Version"
Call :Color C " 20"
Call :Color F "" \n
Call :Color 9 "##################" \n
Pause >Nul
Exit /B
:Color
:: v20 deprecated.
:: Arguments: hexColor text [\n]
:: Supported in windows XP, 7, 8.
:: In XP extended ascii characters are printed as dots.
:: For print quotes, use empty text.
SetLocal EnableExtensions EnableDelayedExpansion
Set "Text=%~2"
If Not Defined Text (Set Text=^")
Subst `: "!Temp!" >Nul &`: &Cd \
If Not Exist `.7 (
Echo(|(Pause >Nul &Findstr "^" >`)
Set /P "=." >>` <Nul
For /F "delims=;" %%# In (
'"Prompt $H;&For %%_ In (_) Do Rem"') Do (
Set /P "=%%#%%#%%#" <Nul >`.3
Set /P "=%%#%%#%%#%%#%%#" <Nul >`.5
Set /P "=%%#%%#%%#%%#%%#%%#%%#" <Nul >`.7))
Set /P "LF=" <` &Set "LF=!LF:~0,1!"
For %%# in ("!LF!") Do For %%_ In (
\ / :) Do Set "Text=!Text:%%_=%%~#%%_%%~#!"
For /F delims^=^ eol^= %%# in ("!Text!") Do (
If #==#! SetLocal DisableDelayedExpansion
If \==%%# (Findstr /A:%~1 . \` Nul
Type `.3) Else If /==%%# (Findstr /A:%~1 . /.\` Nul
Type `.5) Else (Echo %%#\..\`>`.dat
Findstr /F:`.dat /A:%~1 .
Type `.7))
If "\n"=="%~3" (Echo()
Goto :Eof