接受颜色名称、小数和十六进制参数的批处理颜色脚本
我刚刚完成了一个批量颜色脚本,它接受颜色名称、小数和十六进制参数。
该脚本的工作方式与 MS-Color 命令完全相同,但它也接受 小数点和颜色名称。
运行此脚本(不带边界)以获得完整说明(包括语法和用法)。
我想知道我是否做得很好或者有什么可以改进的地方?
if "%_TPfore%"=="A" set "_ValidF=TRUE" && goto TWOPAR_VALID
@echo off
setlocal EnableDelayedExpansion
if "%1"=="/?" goto HELP
if "%1"=="" goto HELP
goto BYPASSREMSTATEMENTS
rem ***********************************************************
rem * Easycolor was created by Edoctoor 2010 *
rem * With the help from the good people at stackoverflow.com *
rem * For the good people at stackoverflow.com *
rem * *
rem * Convert Color-name and Decimals Parmeters to Hex values *
rem * then pass the VALUES to the COLOR COMMAND *
rem ***********************************************************
:BYPASSREMSTATEMENTS
set "_DEBUGGING=FALSE"
If "%_DEBUGGING%"=="TRUE" prompt=$g && echo on && cls
REM IF TWO PARMETERS GIVEN
IF NOT "%2"=="" call :TWOPAR %1 %2
REM IF ONE PARMETER GIVEN
set _OPback=%1
call :TWOPAR %_OPback:~0,1% %_OPback:~1,1%
goto :eof
rem ***********************************************************
rem * Convert Color-name and Decimals Parmeters to Hex values *
rem * then pass the VALUES to the COLOR COMMAND *
rem ***********************************************************
:TWOPAR
set "_TPback=%1"
set "_TPfore=%2"
set "_ValidB=FALSE"
set "_ValidF=FALSE"
FOR /L %%B IN (1,1,9) DO (
if "%_TPback%"=="%%B" set "_ValidB=TRUE" && goto TWOPAR_FORE
)
if /I "%_TPback%"=="Black" set /A _TPback=0 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Blue" set /A _TPback=1 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Green" set /A _TPback=2 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Aqua" set /A _TPback=3 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Red" set /A _TPback=4 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Purple" set /A _TPback=5 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Yellow" set /A _TPback=6 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="White" set /A _TPback=7 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Gray" set /A _TPback=8 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightBlue" set /A _TPback=9 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightGreen" set _TPback=A && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightAqua" set _TPback=B && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightRed" set _TPback=C && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightPurple" set _TPback=D && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightYellow" set _TPback=E && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="BrightWhite" set _TPback=F && set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="A" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="B" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="C" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="D" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="E" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="F" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="a" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="b" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="c" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="d" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="e" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="f" set "_ValidB=TRUE" && goto TWOPAR_FORE
:TWOPAR_FORE
FOR /L %%B IN (1,1,9) DO (
if "%_TPfore%"=="%%B" set "_ValidF=TRUE" && goto TWOPAR_VALID
)
if /I "%_TPfore%"=="Black" set /A _TPfore=0 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Blue" set /A _TPfore=1 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Green" set /A _TPfore=2 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Aqua" set /A _TPfore=3 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Red" set /A _TPfore=4 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Purple" set /A _TPfore=5 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Yellow" set /A _TPfore=6 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="White" set /A _TPfore=7 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Gray" set /A _TPfore=8 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightBlue" set /A _TPfore=9 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightGreen" set _TPfore=A && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightAqua" set _TPfore=B && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightRed" set _TPfore=C && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightPurple" set _TPfore=D && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightYellow" set _TPfore=E && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="BrightWhite" set _TPfore=F && set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="A" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="B" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="C" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="D" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="E" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="F" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="a" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="b" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="c" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="d" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="e" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="f" set "_ValidF=TRUE" && goto TWOPAR_VALID
:TWOPAR_VALID
If "%_DEBUGGING%"=="TRUE" (
echo TWOPAR Background is %_TPback% %_ValidB%
echo TWOPAR Foreground is %_TPfore% %_ValidF%
pause
)
rem I think I can remove this as the color command
rem will provide the errolevel if the values are equal...
rem Is that right?
rem if Background Parameter matches Foreground ignore
rem IF "%_TPback%"=="%_TPfore%" (
rem set _TrueIFMatch=%errorlevel%
rem exit %_TrueIFMatch%
rem )
if "%_ValidB%"=="TRUE" (
if "%_ValidF%"=="TRUE" (
color %_TPback%%_TPfore%
)
)
exit /B
rem ***********************************************************
rem * Display Help and exit *
rem ***********************************************************
:HELP
@echo off
echo.
echo Sets the default console background and foreground text colors.
echo.
echo EASYCOLOR ^[Background Decimal Code^] ^[Text Decimal Code^]
echo EASYCOLOR ^[Background Color-Name^] ^[Text Color-Name^]
echo.
echo EASYCOLOR is compatable with the COLOR command see color /?
echo.
echo EASYCOLOR ^[Background HEX CODE Text HEX CODE^]
echo.
echo Color attributes are specified by Decimal, Color-Names, or Hex digits
echo The first ^(Decimal, Color-Names, Hex^) value corresponds to the background color;
echo the second ^(Decimal, Color-Names, Hex^) value corresponds to the text color.
echo Each attribute can be any of the following values:
echo.
echo Decimal == Color-Names == Hex
echo _____________________________
echo 0 == Black ======== 0
echo 1 == Blue ========= 1
echo 2 == Green ======== 2
echo 3 == Aqua ========= 3
echo 4 == Red ========== 4
echo 5 == Purple ======= 5
echo 6 == Yellow ======= 6
echo 7 == White ======== 7
echo 8 == Gray ========= 8
echo 9 == LightBlue ==== 9
echo 10 == LightGreen === A
echo 11 == LightAqua ==== B
echo 12 == LightRed ===== C
echo 13 == LightPurple == D
echo 14 == LightYellow == E
echo 15 == BrightWhite == F
echo.
echo Help Examples:
echo.
echo EASYCOLOR ^> produces this help screen.
echo EASYCOLOR /? ^> produces this help screen.
echo.
echo Decimal and Color-Names Examples:
echo.
echo EASYCOLOR 7 0 ^> White background with Black text.
echo EASYCOLOR Blue White ^> Blue background with White text.
echo EASYCOLOR 0 LightGreen ^> Black background with LightGreen text.
echo.
echo Color command and compatable Hex Examples:
echo (Note: Hex is assumed if no space between attributes)
echo.
echo EASYCOLOR 0F ^> Black background with BrightWhite text.
echo EASYCOLOR 1B ^> Blue background with LightAqua text.
echo.
echo Note
echo.
echo EASYCOLOR 0brightwhite ^> Black background with LightAqua text.
echo Because there wasn't a space between 0 and brightwhite
echo the HEX value of 0b is assumed; wrongly.
echo.
echo EASYCOLOR 0 brightwhite ^> Black background with brightwhite text.
echo as expected.
echo.
echo The EASYCOLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
echo the EASYCOLOR command with a foreground and background color that are the
echo same.
echo.
echo.
exit /B
I just finished my a Batch COLOR script that accepts Color-names, Decimals and Hex Parameters.
This script works exactly like the MS-Color command but it also accepts
decimals and color-names.
Run this script without perimeters for a full description including syntax and usage.
I am wondering if I did a good job or is there something that can be improved?
if "%_TPfore%"=="A" set "_ValidF=TRUE" && goto TWOPAR_VALID
@echo off
setlocal EnableDelayedExpansion
if "%1"=="/?" goto HELP
if "%1"=="" goto HELP
goto BYPASSREMSTATEMENTS
rem ***********************************************************
rem * Easycolor was created by Edoctoor 2010 *
rem * With the help from the good people at stackoverflow.com *
rem * For the good people at stackoverflow.com *
rem * *
rem * Convert Color-name and Decimals Parmeters to Hex values *
rem * then pass the VALUES to the COLOR COMMAND *
rem ***********************************************************
:BYPASSREMSTATEMENTS
set "_DEBUGGING=FALSE"
If "%_DEBUGGING%"=="TRUE" prompt=$g && echo on && cls
REM IF TWO PARMETERS GIVEN
IF NOT "%2"=="" call :TWOPAR %1 %2
REM IF ONE PARMETER GIVEN
set _OPback=%1
call :TWOPAR %_OPback:~0,1% %_OPback:~1,1%
goto :eof
rem ***********************************************************
rem * Convert Color-name and Decimals Parmeters to Hex values *
rem * then pass the VALUES to the COLOR COMMAND *
rem ***********************************************************
:TWOPAR
set "_TPback=%1"
set "_TPfore=%2"
set "_ValidB=FALSE"
set "_ValidF=FALSE"
FOR /L %%B IN (1,1,9) DO (
if "%_TPback%"=="%%B" set "_ValidB=TRUE" && goto TWOPAR_FORE
)
if /I "%_TPback%"=="Black" set /A _TPback=0 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Blue" set /A _TPback=1 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Green" set /A _TPback=2 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Aqua" set /A _TPback=3 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Red" set /A _TPback=4 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Purple" set /A _TPback=5 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Yellow" set /A _TPback=6 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="White" set /A _TPback=7 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="Gray" set /A _TPback=8 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightBlue" set /A _TPback=9 && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightGreen" set _TPback=A && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightAqua" set _TPback=B && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightRed" set _TPback=C && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightPurple" set _TPback=D && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="LightYellow" set _TPback=E && set "_ValidB=TRUE" && goto TWOPAR_FORE
if /I "%_TPback%"=="BrightWhite" set _TPback=F && set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="A" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="B" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="C" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="D" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="E" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="F" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="a" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="b" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="c" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="d" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="e" set "_ValidB=TRUE" && goto TWOPAR_FORE
if "%_TPback%"=="f" set "_ValidB=TRUE" && goto TWOPAR_FORE
:TWOPAR_FORE
FOR /L %%B IN (1,1,9) DO (
if "%_TPfore%"=="%%B" set "_ValidF=TRUE" && goto TWOPAR_VALID
)
if /I "%_TPfore%"=="Black" set /A _TPfore=0 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Blue" set /A _TPfore=1 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Green" set /A _TPfore=2 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Aqua" set /A _TPfore=3 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Red" set /A _TPfore=4 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Purple" set /A _TPfore=5 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Yellow" set /A _TPfore=6 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="White" set /A _TPfore=7 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="Gray" set /A _TPfore=8 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightBlue" set /A _TPfore=9 && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightGreen" set _TPfore=A && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightAqua" set _TPfore=B && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightRed" set _TPfore=C && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightPurple" set _TPfore=D && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="LightYellow" set _TPfore=E && set "_ValidF=TRUE" && goto TWOPAR_VALID
if /I "%_TPfore%"=="BrightWhite" set _TPfore=F && set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="A" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="B" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="C" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="D" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="E" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="F" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="a" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="b" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="c" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="d" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="e" set "_ValidF=TRUE" && goto TWOPAR_VALID
if "%_TPfore%"=="f" set "_ValidF=TRUE" && goto TWOPAR_VALID
:TWOPAR_VALID
If "%_DEBUGGING%"=="TRUE" (
echo TWOPAR Background is %_TPback% %_ValidB%
echo TWOPAR Foreground is %_TPfore% %_ValidF%
pause
)
rem I think I can remove this as the color command
rem will provide the errolevel if the values are equal...
rem Is that right?
rem if Background Parameter matches Foreground ignore
rem IF "%_TPback%"=="%_TPfore%" (
rem set _TrueIFMatch=%errorlevel%
rem exit %_TrueIFMatch%
rem )
if "%_ValidB%"=="TRUE" (
if "%_ValidF%"=="TRUE" (
color %_TPback%%_TPfore%
)
)
exit /B
rem ***********************************************************
rem * Display Help and exit *
rem ***********************************************************
:HELP
@echo off
echo.
echo Sets the default console background and foreground text colors.
echo.
echo EASYCOLOR ^[Background Decimal Code^] ^[Text Decimal Code^]
echo EASYCOLOR ^[Background Color-Name^] ^[Text Color-Name^]
echo.
echo EASYCOLOR is compatable with the COLOR command see color /?
echo.
echo EASYCOLOR ^[Background HEX CODE Text HEX CODE^]
echo.
echo Color attributes are specified by Decimal, Color-Names, or Hex digits
echo The first ^(Decimal, Color-Names, Hex^) value corresponds to the background color;
echo the second ^(Decimal, Color-Names, Hex^) value corresponds to the text color.
echo Each attribute can be any of the following values:
echo.
echo Decimal == Color-Names == Hex
echo _____________________________
echo 0 == Black ======== 0
echo 1 == Blue ========= 1
echo 2 == Green ======== 2
echo 3 == Aqua ========= 3
echo 4 == Red ========== 4
echo 5 == Purple ======= 5
echo 6 == Yellow ======= 6
echo 7 == White ======== 7
echo 8 == Gray ========= 8
echo 9 == LightBlue ==== 9
echo 10 == LightGreen === A
echo 11 == LightAqua ==== B
echo 12 == LightRed ===== C
echo 13 == LightPurple == D
echo 14 == LightYellow == E
echo 15 == BrightWhite == F
echo.
echo Help Examples:
echo.
echo EASYCOLOR ^> produces this help screen.
echo EASYCOLOR /? ^> produces this help screen.
echo.
echo Decimal and Color-Names Examples:
echo.
echo EASYCOLOR 7 0 ^> White background with Black text.
echo EASYCOLOR Blue White ^> Blue background with White text.
echo EASYCOLOR 0 LightGreen ^> Black background with LightGreen text.
echo.
echo Color command and compatable Hex Examples:
echo (Note: Hex is assumed if no space between attributes)
echo.
echo EASYCOLOR 0F ^> Black background with BrightWhite text.
echo EASYCOLOR 1B ^> Blue background with LightAqua text.
echo.
echo Note
echo.
echo EASYCOLOR 0brightwhite ^> Black background with LightAqua text.
echo Because there wasn't a space between 0 and brightwhite
echo the HEX value of 0b is assumed; wrongly.
echo.
echo EASYCOLOR 0 brightwhite ^> Black background with brightwhite text.
echo as expected.
echo.
echo The EASYCOLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
echo the EASYCOLOR command with a foreground and background color that are the
echo same.
echo.
echo.
exit /B
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个脚本不错。
但我在这里发现一个错误
如果存在两个参数,则调用 :TWOPAR,但它会返回,因此“ONE PARMETER GIVEN”部分也将被执行。
以及另一个一般代码建议。
不要重复自己:-)
如果代码块几乎相同,最好将它们合并到一个函数中。
就像您对背景颜色和前景颜色的颜色名称的两次验证一样。
希望有帮助
杰布
nice script for the first one.
But one error I found here
If two parameters present, you call :TWOPAR, but it will return, so the "ONE PARMETER GIVEN" part will also be executed.
And another general code suggestions.
Don't repeat yourself :-)
If code blocks are nearly same, it is better to merge them to a function.
Like your two verifications of the color names for the background and forground color.
hope it helps
jeb