How to use function in function library ?
Posted: 26 Mar 2013 10:49
Hello,
i like your function library http://www.dostips.com/DtCodeCmdLib.php
but i don't understand how can i use it
i try this code but i have an error on line : " )|debug>NUL "
have you an idea ?
http://www.dostips.com/DtCodeCmdLib.php
i like your function library http://www.dostips.com/DtCodeCmdLib.php
but i don't understand how can i use it
i try this code but i have an error on line : " )|debug>NUL "
have you an idea ?
Code: Select all
::========================================================================
cls
@ECHO OFF
REM.-- Prepare the Command Processor
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
REM.-- your code goes here
call:Init
echo.Hello World
call:echo 2E. "test"
echo.color2
call:echo 7C. "qsdfghjklm"
REM.-- End of application
ECHO.&ECHO.Press any key to end the application.
PAUSE>NUL&GOTO:EOF
::------------------------------------------------------------------------
:Init -- initializes the environment for this command library
::$created 20060101 :$changed 20080219
::$source http://www.dostips.com
set ".=%~f0" & rem set full name, i.e. type %.%
set ":=call "%.%" " & rem set cl call prefix, i.e. %:%:func
set "?=&&echo.TRUE||echo.FALSE" & rem set true/false check, i.e. %:%:true %?%
set "*=%:%:set " & rem set array setter for console output, i.e. %*% d=dir /b
if not exist "%temp%" set "temp=%tmp%"
if not exist "%temp%" set "temp=c:\temp"
if not exist "%temp%" md "%temp%"
EXIT /b
:echo col txt -- echoes text in a specific color
:: -- col [in] - color code, append a DOT to omit line break, call 'color /?' for color codes
:: -- txt [in] - text output
::$created 20060101 :$changed 20080219 :$categories Echo,Color
::$source http://www.dostips.com
SETLOCAL
for /f "tokens=1,*" %%a in ("%*") do (
set col=%%a
set txt=%%~b
)
set cr=Y
if "%col:~-1%"=="." (
set cr=N
set col=%col:~0,-1%
)
call:getColorCode "%col%" col
::set col=2E
set com=%temp%.\color%col%.com
echo ici
if not exist "%com%" (
echo.N %COM%
echo.A 100
echo.MOV BL,%col%
echo.MOV BH,0
echo.MOV SI,0082
echo.MOV AL,[SI]
echo.MOV CX,1
echo.MOV AH,09
echo.INT 10
echo.MOV AH,3
echo.INT 10
echo.INC DL
echo.MOV AH,2
echo.INT 10
echo.INC SI
echo.MOV AL,[SI]
echo.CMP AL,0D
echo.JNZ 109
echo.RET
echo.
echo.r cx
echo.22
echo.w
echo.q
)|debug>NUL
echo la
"%com%" %txt%
rem del "%com%" /q
if "%cr%"=="Y" echo.
EXIT /b
:getColorCode col ret -- converts color text to color code
:: -- col [in] - color text BackgroundForeground, i.e.: BlueLYellow for 1E
:: -- ret [out] - return variable to return color code in
::$created 20060101 :$changed 20080219 :$categories Color,Echo
::$source http://www.dostips.com
SETLOCAL
set col=%~1
set col=%col:Gray=8%
set col=%col:LBlue=9%
set col=%col:LGreen=A%
set col=%col:LAqua=B%
set col=%col:LRed=C%
set col=%col:LPurple=D%
set col=%col:LYellow=E%
set col=%col:LWhite=F%
set col=%col:Black=0%
set col=%col:Blue=1%
set col=%col:Green=2%
set col=%col:Aqua=3%
set col=%col:Red=4%
set col=%col:Purple=5%
set col=%col:Yellow=6%
set col=%col:White=7%
ENDLOCAL & IF "%~2" NEQ "" (SET %~2=%col%) ELSE (echo.%col%)
EXIT /b
http://www.dostips.com/DtCodeCmdLib.php