echo off
echo [0m
echo [2J
echo [1;1HÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Set screen color attributes                       ³
echo ³ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 21-Oct-90 ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.

rem If you get an "Out of environment space" message, increase your
rem environment space by using shell configuration in config.sys:
rem MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p

rem If no parameters, show the color table
if "%1"=="" goto _help

rem Make the TextColor parameter uppercase
set tmp_=%path%
path=%1
set upcase1_=%path%
path=%tmp_%

rem Make the BackgroundColor parameter uppercase
set upcase2_=
if "%2"=="" goto _assign
set tmp_=%path%
path=%2
set upcase2_=%path%
path=%tmp_%

:_assign
rem Set the appropriate ansi codes into variables
set text_=InvalidTextColor
for %%n in (0 BLACK) do if "%%n"=="%upcase1_%" set text_=[30m
for %%n in (1 BLUE) do if "%%n"=="%upcase1_%" set text_=[34m
for %%n in (2 GREEN) do if "%%n"=="%upcase1_%" set text_=[32m
for %%n in (3 CYAN) do if "%%n"=="%upcase1_%" set text_=[36m
for %%n in (4 RED) do if "%%n"=="%upcase1_%" set text_=[31m
for %%n in (5 MAGENTA) do if "%%n"=="%upcase1_%" set text_=[35m
for %%n in (6 BROWN) do if "%%n"=="%upcase1_%" set text_=[33m
for %%n in (7 LIGHTGRAY) do if "%%n"=="%upcase1_%" set text_=[37m
for %%n in (9 LIGHTGBLUE) do if "%%n"=="%upcase1_%" set text_=[34;1m
for %%n in (10 LIGHTGREEN) do if "%%n"=="%upcase1_%" set text_=[32;1m
for %%n in (11 LIGHTCYAN) do if "%%n"=="%upcase1_%" set text_=[36;1m
for %%n in (12 LIGHTRED) do if "%%n"=="%upcase1_%" set text_=[31;1m
for %%n in (13 LIGHTMAGENTA) do if "%%n"=="%upcase1_%" set text_=[35;1m
for %%n in (14 YELLOW) do if "%%n"=="%upcase1_%" set text_=[33;1m
for %%n in (15 WHITE) do if "%%n"=="%upcase1_%" set text_=[37;1m

if not "%2"=="" set back_=InvalidBckColor
for %%n in (0 BLACK) do if "%%n"=="%upcase2_%" set back_=[40m
for %%n in (1 BLUE) do if "%%n"=="%upcase2_%" set back_=[44m
for %%n in (2 GREEN) do if "%%n"=="%upcase2_%" set back_=[42m
for %%n in (3 CYAN) do if "%%n"=="%upcase2_%" set back_=[46m
for %%n in (4 RED) do if "%%n"=="%upcase2_%" set back_=[41m
for %%n in (5 MAGENTA) do if "%%n"=="%upcase2_%" set back_=[45m
for %%n in (6 BROWN) do if "%%n"=="%upcase2_%" set back_=[43m
for %%n in (7 LIGHTGRAY) do if "%%n"=="%upcase2_%" set back_=[47m

rem Were the color parameters valid
if "%text_%"=="InvalidTextColor" goto _err1
if "%back_%"=="InvalidBckColor" goto _err2

rem Set the new color attributes and clear the screen
echo %text_%
if not "%back_%"=="" echo %back_%
echo [2J
goto _out

:_err1
echo Invalid TextColor %1
goto _out

:_err2
echo Invalid BackgroundColor %2
goto _out

:_help
echo Usage: COLOR TextColor[orNumber] [BackgroundColor[orNumber]]
echo.
echo [30;47m0 Black[0m
echo [34m1 Blue[0m
echo [32m2 Green[0m
echo [36m3 Cyan[0m
echo [31m4 Red[0m
echo [35m5 Magenta[0m
echo [33m6 Brown[0m
echo [37m7 LightGray[0m
echo [34;1m9 LightBlue[0m
echo [32;1m10 LightGreen[0m
echo [36;1m11 LightCyan[0m
echo [31;1m12 LightRed[0m
echo [35;1m13 LightMagenta[0m
echo [33;1m14 Yellow[0m
echo [37;1m15 White[0m
goto _out

:_out
set upcase1_=
set upcase2_=
set text_=
set back_=
echo on
