Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & MODE CON: cols=110 lines=140
- REM - Required
- SETLOCAL EnableDelayedExpansion
- REM - Used in Function to Remove the Prompt.
- For /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
- set "DEL=%%a"
- )
- REM - Creates Color chart - To demonstrate the function
- For %%F in (a,b,c,d,e,f,1,2,3,4,5,6,7,8,9,0) Do (
- For %%B in (a,b,c,d,e,f,1,2,3,4,5,6,7,8,9,0) Do (
- IF NOT %%B==%%F (Call :Colorize %%F%%B "Color %%F%%B I")
- )
- ECHO( Next...
- Pause >nul
- CLS
- )
- REM - New Lines need to be Forced While Using the Colorizer
- ECHO(
- REM - Example of printing multiple colors on same line:
- REM - Note: spaces at the end of strings will be stripped.
- CALL :Colorize 0a "Hello World " && CALL :Colorize 0c " What's Up" && CALL :Colorize 8f " Good People"
- ECHO.
- CALL :Colorize 0f "Colored by T3RRY"
- ECHO.
- REM - End of Demonstration
- pause
- goto :eof
- REM - Colorize function. To use: CALL : Colorize <colorcode> <"String in quotes">
- REM - Function works by creating a temporary file named using the string and Printing it Colored with FINDSTR
- :Colorize
- IF NOT EXIST "%TEMP%\colorize" md "%TEMP%\colorize"
- PUSHD %TEMP%\colorize
- <nul set /p ".=%DEL%" > "%~2"
- findstr /v /a:%1 /R "^$" "%~2" nul
- del "%~2" > nul 2>&1
- POPD
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment