colorChanger : optimize Code ?
Posted: 31 Jul 2009 06:59
can anyone help me optimize this code, i don't know how to in dos, in other programming languages i'd know but not here :/
what i'm trying to achieve is that the foregroundChange and backgroundChange use the same function, instead of having 2 ( practically the same functions ).
is there a way to do so ?
what i'm trying to achieve is that the foregroundChange and backgroundChange use the same function, instead of having 2 ( practically the same functions ).
is there a way to do so ?
Code: Select all
:colorChanger
echo.
echo to get a quick list of the available colors
echo type colorHelp
echo.
set input=
set /p input=Background Color:
if not defined input (echo.
echo color not found
echo.
goto a)
goto kleurenBackground
:kleurenBackground
if "%INPUT%"=="black" (set Background=0
goto kleurenForeground)
if "%INPUT%"=="blue" (set Background=1
goto kleurenForeground)
if "%INPUT%"=="green" (set Background=2
goto kleurenForeground)
if "%INPUT%"=="aqua" (set Background=3
goto kleurenForeground)
if "%INPUT%"=="red" (set Background=4
goto kleurenForeground)
if "%INPUT%"=="purple" (set Background=5
goto kleurenForeground)
if "%INPUT%"=="yellow" (set Background=6
goto kleurenForeground)
if "%INPUT%"=="white" (set Background=7
goto kleurenForeground)
if "%INPUT%"=="gray" (set Background=8
goto kleurenForeground)
if "%INPUT%"=="light blue" (set Background=9
goto kleurenForeground)
if "%INPUT%"=="light green" (set Background=A
goto kleurenForeground)
if "%INPUT%"=="light aqua" (set Background=B
goto kleurenForeground)
if "%INPUT%"=="light red" (set Background=C
goto kleurenForeground)
if "%INPUT%"=="light purple" (set Background=D
goto kleurenForeground)
if "%INPUT%"=="light yellow" (set Background=E
goto kleurenForeground)
if "%INPUT%"=="bright white" (set Background=F
goto kleurenForeground)
if "%INPUT%"=="colorHelp" (goto colorHelp)
if "%INPUT%"=="default" (color 0A
goto a)
echo.
echo Color Not Found
echo.
goto a
:kleurenForeground
set input=
set /p input=Foreground Color:
if not defined input (echo.
echo color not found
echo.
goto a)
if "%INPUT%"=="black" (set Foreground=0
goto kleurenSetter)
if "%INPUT%"=="blue" (set Foreground=1
goto kleurenSetter)
if "%INPUT%"=="green" (set Foreground=2
goto kleurenSetter)
if "%INPUT%"=="aqua" (set Foreground=3
goto kleurenSetter)
if "%INPUT%"=="red" (set Foreground=4
goto kleurenSetter)
if "%INPUT%"=="purple" (set Foreground=5
goto kleurenSetter)
if "%INPUT%"=="yellow" (set Foreground=6
goto kleurenSetter)
if "%INPUT%"=="white" (set Foreground=7
goto kleurenSetter)
if "%INPUT%"=="gray" (set Foreground=8
goto kleurenSetter)
if "%INPUT%"=="light blue" (set Foreground=9
goto kleurenSetter)
if "%INPUT%"=="light green" (set Foreground=A
goto kleurenSetter)
if "%INPUT%"=="light aqua" (set Foreground=B
goto kleurenSetter)
if "%INPUT%"=="light red" (set Foreground=C
goto kleurenSetter)
if "%INPUT%"=="light purple" (set Foreground=D
goto kleurenSetter)
if "%INPUT%"=="light yellow" (set Foreground=E
goto kleurenSetter)
if "%INPUT%"=="bright white" (set Foreground=F
goto kleurenSetter)
if "%INPUT%"=="colorHelp" (goto colorHelp)
if "%INPUT%"=="default" (color 0A
goto a)
echo.
echo Color Not Found
echo.
goto a
:kleurenSetter
color %Background%%Foreground%
echo.
echo. do you wish to keep these changes ?
echo.
echo 1 - yes
echo 2 - no
echo.
choice /c:12
if errorlevel 2 (color 0A
goto a)
if errorlevel 1 goto a
:colorHelp
echo -----------------------------------------
echo ----------- Available Colors ------------
echo -----------------------------------------
echo.
echo ^>^>^>^>^> reminder : don't use cases
echo.
echo - black
echo - blue
echo - green
echo - aqua
echo - red
echo - purple
echo - yellow
echo - white
echo - gray
echo - light blue
echo - light green
echo - light aqua
echo - light red
echo - light purple
echo - light yellow
echo - bright white
echo - default
echo -
echo -----------------------------------------
timeout -1
goto colorChanger