Page 1 of 1

How to use function in function library ?

Posted: 26 Mar 2013 10:49
by alban.lopez
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 ?

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

Re: How to use function in function library ?

Posted: 26 Mar 2013 10:57
by mfm4aa
What is the error message?

Re: How to use function in function library ?

Posted: 26 Mar 2013 13:45
by Squashman
Debug is not going to work in 64bit versions of Windows.

Re: How to use function in function library ?

Posted: 27 Mar 2013 02:27
by alban.lopez
i use a Win7 64bits :|

i have this message :

in frensh

Code: Select all

Hello World
'debug' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.


in english :

Code: Select all

'Debug' is not recognized as an internal control
or external, operable program or batch file.

Re: How to use function in function library ?

Posted: 29 Mar 2013 13:43
by Aacini
If you want to show color text in the screen, you may use my ColorShow.exe auxiliary program; for example:

Code: Select all

ColorShow "Hello World" 13 10 /2E "test" / " color2 " /7C "qsdfghjklm"

Output:
Output wrote:Hello World
test color2 qsdfghjklm

In previous output, "test" is yellow on green and "qsdfghjklm" is light red on white.

    To get ColorShow.exe file, follow these steps:
  • Copy ColorShow.exe.hex file from this site; look for program number 12.
  • Copy both HexToBin.bat and HexChar.vbs files from this site.
  • Execute: HexToBin ColorShow.exe.hex

Tested on Win8 64 bits.

Antonio