How to use function in function library ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alban.lopez
Posts: 2
Joined: 26 Mar 2013 10:28

How to use function in function library ?

#1 Post by alban.lopez » 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 ?

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

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: How to use function in function library ?

#2 Post by mfm4aa » 26 Mar 2013 10:57

What is the error message?

Squashman
Expert
Posts: 4477
Joined: 23 Dec 2011 13:59

Re: How to use function in function library ?

#3 Post by Squashman » 26 Mar 2013 13:45

Debug is not going to work in 64bit versions of Windows.

alban.lopez
Posts: 2
Joined: 26 Mar 2013 10:28

Re: How to use function in function library ?

#4 Post by alban.lopez » 27 Mar 2013 02:27

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.

Aacini
Expert
Posts: 1888
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: How to use function in function library ?

#5 Post by Aacini » 29 Mar 2013 13:43

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

Post Reply