Impresión de Códigos de Barra

Impresión de Códigos de Barra

Postby leandro » Thu Apr 30, 2015 2:43 pm

Buenas Tardes para todos...

Antonio que pena molestar, pero es que requiero imprimir codigos de barras
en la impresora por bluetooth, ya logre realizar la impresion de texto.

Pero ahora necesito imprimir un codigo de barras..

¿Como puedo hacer esto?
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1480
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Impresión de Códigos de Barra Con la BARLIB de Cayetano Gome

Postby FiveWiDi » Thu Apr 30, 2015 3:56 pm

Si te refieres a hacer algo así:
@ nCmRow, nCmCol ;
CODE128 ;
"cMiLiteralacodificar" ;
MODE "A" OF oMiObjetoPrinter SIZE 1

Debes añadir a tu programa:
-en la carpeta del include: el CH BARCODE.CH
-y en la carpeta de tus PRG los siguientes: BANNER.PRG, BARLIB.PRG, CODABAR.PRG, CODE3DE9.PRG, CODE128.PRG, EAN13.PRG, GO_CODE.PRG y INT25.PRG

Gentileza de Cayetano.

Code: Select all  Expand view
BARCODE.CH
==========
#ifndef _BARCODE_
#define _BARCODE_

#translate @ <nRow>, <nCol> CODE128  <cCode> ;
                [ MODE <cMode>] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                => ;
        Code128( <nRow>, <nCol> , <cCode>, <oPrint>, <cMode> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )

#translate @ <nRow>, <nCol> CM_CODE128  <cCode> ;
                [ MODE <cMode>] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                => ;
        c_Code128( <nRow>, <nCol> , <cCode>, <oPrint>, <cMode> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )

#translate @ <nRow>, <nCol> CODE3_9  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        Code3_9( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> CM_CODE3_9  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        c_Code3_9( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> EAN13  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        EAN13( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont> )



#translate @ <nRow>, <nCol> CM_EAN13  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        c_EAN13( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )

#translate @ <nRow>, <nCol> UPCA  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        UPCA( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )



#translate @ <nRow>, <nCol> CM_UPCA  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        c_UPCA( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )


#translate @ <nRow>, <nCol> EAN8  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        EAN8( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )



#translate @ <nRow>, <nCol> CM_EAN8  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        c_EAN8( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )


#translate @ <nRow>, <nCol> SUP5  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        SUP5( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )



#translate @ <nRow>, <nCol> CM_SUP5  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                [ <lBanner:BANNER> ] ;
                [ FONT <cFont> ] ;
                => ;
        c_SUP5( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize>,;
                 <.lBanner.>, <cFont>  )


#translate @ <nRow>, <nCol> CODABAR  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>] ;
                => ;
        CODABAR( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> CM_CODABAR  <cCode> ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]  ;
                => ;
        c_CODABAR( <nRow>, <nCol> , <cCode>, <oPrint> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )

#translate @ <nRow>, <nCol> INT25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        INT25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> CM_INT25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        c_INT25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )


#translate @ <nRow>, <nCol> IND25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        IND25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> CM_IND25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        c_IND25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )


#translate @ <nRow>, <nCol> MAT25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        MAT25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )



#translate @ <nRow>, <nCol> CM_MAT25  <cCode> ;
                [ <lCheck:CHECK> ] ;
                [ <lVert:VERTICAL> ];
                [ COLOR <nColor> ] ;
                [ WIDTH <nWidth> ] ;
                [ SIZE <nSize> ] ;
                [ OF <oPrint>]   ;
                => ;
        c_MAT25( <nRow>, <nCol> , <cCode>, <oPrint>, <lCheck> ;
                ,<nColor>, .not. <.lVert.>, <nWidth>, <nSize> )

#ENDIF

Code: Select all  Expand view
BANNER.PRG
==========
// labels on barcodes

#include "fivewin.ch"

function barlen13(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nLen,cFont)
    local oFont, nLenChar, l ,Control,k,n,nWidthChar

    default lHorz := .t.

    default nWidth := 0.025 // 1/3 M/mm

    default nLen := 1.5 // Cmm.

    default cFont := 'arial'

    default Color := CLR_BLACK

    k:=left(alltrim(cCode)+'000000000000',12) // padding with '0'
    // calculo del digito de control
     k:=k+EAN13_CHECK(k)                           // Chaeck Digit en EAN13
    if !lHorz
        nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nWidth :=round  ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end
    // Len of bar
    if lHorz
        nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nLen :=round  ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end


/*
        nLenChar := nWidth*10
        nWidthChar:= nLen*0.3
        while .t.
            define font oFont name cFont of oPrInt size nLenChar , nLenChar/2 ;
                nescapement if(lHorz,0,13500)
            if oPrint:GetTextWidth( '888888', oFont )<=42*nWidth
                // alert(if(lHorz,'H:','V:')+str(nWidth*7)+str(nLenChar/(nWidth*7)))
                while .t.
                    define font oFont name cFont of oPrInt size nLenChar , nWidthChar ;
                        nescapement if(lHorz,0,13500)
                    if oPrint:GetTextHeigth( '8', oFont )<=0.2*nLen
                        alert(if(lHorz,'H:','V:')+str(nLen*0.2)+str(nWidthChar/(nLen*0.2)))
                        exit
                    else
                        nWidthChar-=0.2
                    end
                    oFont:end()
                enddo
                exit
            else
                nLenChar-=1
            end
            oFont:end()
        end
 *   nWidt -> 0.8
*/


    define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
                nescapement if(lHorz,0,13500)

    if lHorz
        oPrint:say(nRow+nLen*0.9,nCol-nWidth*8,left(k,1),oFont,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*3,substr(k,2,6),oFont,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*50,substr(k,8,6),oFont,,Color)
    else
        oPrint:say(nRow-nWidth*8,nCol+nLen*0.1,left(k,1),oFont,,Color)
        oPrint:say(nRow+nWidth*3,nCol+nLen*0.1,substr(k,2,6),oFont,,Color)
        oPrint:say(nRow+nWidth*50,nCol+nLen*0.1,substr(k,8,6),oFont,,Color)
    end
    release oFont
return nil



function barlen(cCode,nDigs,oPrint,nRow,nCol,Color,lHorz,nWidth,nLen,cFont)
    local oFont, nLenChar, l ,Control,k,s1,s2,n, Izda, dCha

    default lHorz := .t.

    default nWidth := 0.025 // 1/3 M/mm

    default nLen := 1.5 // Cmm.

    default cFont := 'arial'

    default Color := CLR_BLACK

    default nDigs := 11

    // calculo del digito de control
    k:=left(alltrim(cCode)+'000000000000',nDigs) // padding with '0'
    // calculo del digito de control
    k=k+Upc_CHECK(cCode,nDigs)                     // cCode,nLen
    nDigs++
    dcha:=Right(K,nDigs/2)
    izda:=Left(k,nDigs/2)

    if !lHorz
        nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nWidth :=round  ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end
    // Len of bar
    if lHorz
        nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nLen :=round  ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end

    define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
                nescapement if(lHorz,0,13500)



    // fisrt letter

    if lHorz
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*3,Izda,oFont,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*(int(nDigs)/2*7+8),dcha,oFont,,Color)
    else
        oPrint:say(nRow+nWidth*3,nCol+nLen*0.1,izda,oFont,,Color)
        oPrint:say(nRow+nWidth*(nDigs/2+8),nCol+nLen*0.1,dcha,oFont,,Color)
    end
    release oFont
return nil


function ban5(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nLen,cFont)
    local oFont, nLenChar, k,n, oPen

    default lHorz := .t.

    default nWidth := 0.025 // 1/3 M/mm

    default nLen := 1.5 // Cmm.

    default cFont := 'arial'

    default Color := CLR_BLACK

    ccode:=left(alltrim(cCode)+'000000000000',5) // padding with '0'

    if !lHorz
        nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nWidth :=round  ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end
    // Len of bar
    if lHorz
        nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nLen :=round  ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end



    define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
                nescapement if(lHorz,0,13500)

    define pen oPen color CLR_WHITE of oPrint

    k:=''
    for n:=1 to 4
        k+=substr(cCode,n,1)+ ' '
    end
    cCode := k+right(cCOde,1)

    if lHorz
        oPrint:box(nrow,ncol,nrow+nLen*.3,nCol+48*nWidth,oPen)
    else
        oPrint:box(nrow,ncol,nrow+41*nWidth,nCol+nLen*.3+48*nWidth,oPen)
    end
    oPrint:say(nRow,nCol,cCode,oFont,,Color)
    release oFont
    release oPen
return nil


function UPCA_barlen(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nLen,cFont)
    local oFont, nLenChar, l ,Control,k,n, Izda, dCha, nDigs:=11,oFont2

    default lHorz := .t.

    default nWidth := 0.025 // 1/3 M/mm

    default nLen := 1.5 // Cmm.

    default cFont := 'arial'

    default Color := CLR_BLACK


    // calculo del digito de control
    k:=left(alltrim(cCode)+'000000000000',nDigs) // padding with '0'
    // calculo del digito de control
    k=k+Upc_CHECK(cCode,nDigs)                     // cCode,nLen
    nDigs++
    dcha:=Right(K,nDigs/2)
    izda:=Left(k,nDigs/2)

    if !lHorz
        nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nWidth :=round  ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end
    // Len of bar
    if lHorz
        nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nLen :=round  ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end

    define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
                nescapement if(lHorz,0,13500)
    define font oFont2 name cFont of oPrInt size nWidth*5.6 , nLen*0.025 ;
                nescapement if(lHorz,0,13500)



    // fisrt letter

    if lHorz
        oPrint:say(nRow+nLen*0.9,nCol-nWidth*8,left(k,1),oFont2,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*10,right(Izda,5),oFont,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*50,left(dcha,5),oFont,,Color)
        oPrint:say(nRow+nLen*0.9,nCol+nWidth*95,right(k,1),oFont2,,Color)

    else
        oPrint:say(nRow-nWidth*8,nCol+nLen*0.1,left(k,1),oFont2,,Color)
        oPrint:say(nRow+nWidth*10,nCol+nLen*0.1,right(izda,5),oFont,,Color)
        oPrint:say(nRow+nWidth*50,nCol+nLen*0.1,left(dcha,5),oFont,,Color)
        oPrint:say(nRow+nWidth*95,nCol+nLen*0.1,right(k,1),oFont2,,Color)

    end
    release oFont
    release oFont2    //Afegit 27/05/2010 C.Gelabert
return nil

Code: Select all  Expand view
BARLIB.PRG
==========
// funciones de llamadas de barlib
// chequean las posibles concordancias de datos
// y dan los errores

#include 'fivewin.ch'

// CODE 128

/*

    Code 128:

    Admite los 128 caracteres 0 - 127

    si s¢lo son n£meros se usa un modelo comprimido, llamado
    modo C
    Si hay caracteres < 32 se usa el m¢do A
    Si hay caracteres en minusculas se usa el modo B ( modo por defecto)

    Los modos se mezclan

    Sintaxis :

    code128(nRow,nCol,cCode,oPrint,[cMode],[Color],
           [lOrientacion],[nAncho],[nAlto])

    nRow, nCol en Prixels
    nAncho,nAlto en Cm
*/


Function Code128(nRow,nCol,cCode,oPrint,cMode,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_code128(cCode,cMode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
return nil

Function c_Code128(nRow,nCol,cCode,oPrint,cMode,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return Code128(nRow,nCol,cCode,oPrint,cMode,Color,lHorz,nWidth,nHeigth)


Function Code3_9(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_code3_9(cCode,lCheck),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
return nil

Function c_Code3_9(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return Code3_9(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)

Function ean13(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,;
        lBanner,cFont)
    local nLen
    // test de parametros
    // por implementar
    default nHeigth := 1.5
    default lBanner:=.f.
    // desplazamiento...
    if lHorz
        go_code(_ean13(cCode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    else
        nLen :=round  ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )*0.1
       // 10% espacios
            go_code(_ean13(cCode),nRow,nCol+nLen,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    end
    go_code(_ean13Bl(),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
    if lBanner
        barlen13(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nHeigth,cFont)
    end
return nil


Function c_ean13(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return ean13(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)

Function UPCA(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,lBanner,cFont)
    local nLen
    // test de parametros
    // por implementar
    default nHeigth := 1.5
    default lBanner:=.f.
    if lHorz
        go_code(_UPC(cCode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    else
        nLen :=round  ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )*0.1
       // 10% espacios
            go_code(_UPC(cCode),nRow,nCol+nLen,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    end
    go_code(_UPCABl(cCode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
    if lBanner
        UPCA_barlen(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nHeigth,cFont)
    end
return nil


Function c_UPCA(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return UPCA(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)

Function ean8(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,lBanner,cFont)
    local nLen
    // test de parametros
    // por implementar
    default nHeigth := 1.5
    default lBanner:=.f.
    if lHorz
        go_code(_UPC(cCode,7),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    else
        nLen :=round  ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )*0.1
       // 10% espacios
            go_code(_UPC(cCode,7),nRow,nCol+nLen,oPrint,lHorz,Color,nWidth,nHeigth*0.90)
    end
    go_code(_ean13Bl(8),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
    if lBanner
        barlen(cCode,7,oPrint,nRow,nCol,Color,lHorz,nWidth,nHeigth,cFont)
    end
return nil


Function c_ean8(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return ean8(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)


Function sup5(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,lBanner,cFOnt)
    // test de parametros
    // por implementar
    go_code(_sup5(cCode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
    if lBANNER
        ban5(cCode,oPrint,nRow,nCol,Color,lHorz,nWidth,nhEIGTH,cFont)
    end
return nil

Function c_Sup5(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,lBanner,cFont)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return sup5(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth,lBanner,cFont)


Function Codabar(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_Codabar(cCode),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
return nil

Function c_Codabar(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return Codabar(nRow,nCol,cCode,oPrint,Color,lHorz,nWidth,nHeigth)

Function int25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_int25(cCode,lCheck),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
return nil

Function c_int25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return int25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)

Function ind25(nRow,nCol,cCode,oPrind,lCheck,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_ind25(cCode,lCheck),nRow,nCol,oPrind,lHorz,Color,nWidth,nHeigth)
return nil

Function c_ind25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return ind25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)

Function mat25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    // test de parametros
    // por implementar
    go_code(_mat25(cCode,lCheck),nRow,nCol,oPrint,lHorz,Color,nWidth,nHeigth)
return nil

Function c_mat25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)
    oPrint:Cmtr2Pix(@nRow, @nCol)
return mat25(nRow,nCol,cCode,oPrint,lCheck,Color,lHorz,nWidth,nHeigth)

Code: Select all  Expand view
CODABAR.PRG
===========
// codabar system

static abar:={"101010001110",;
              "101011100010",;
              "101000101110",;
              "111000101010",;
              "101110100010",;
              "111010100010",;
              "100010101110",;
              "100010111010",;
              "100011101010",;
              "111010001010",;
              "101000111010",;
              "101110001010",;
              "11101011101110",;
              "11101110101110",;
              "11101110111010",;
              "10111011101110",;
              "10111000100010",;
              "10001000101110",;
              '10100011100010',;
              '10111000100010',;
              '10001000101110',;
              '10100010001110',;
              '10100011100010'}

static cChar :='0123456789-$:/.+ABCDTN*E'

// importante, this system not test de start /end code.

function _codabar( cCode )
    local n, cBarra := '', nCar
    cCode := upper( cCode )
    for n:=1 to len( cCode )
        if (nCar:=at(substr(cCode,n,1),cChar)) > 0
            cBarra += aBar[ nCar ]
        endif
    next
return cBarra

Code: Select all  Expand view
CODE3DE9.PRG
============
#include 'fivewin.ch'

function _Code3_9( cCode, lCheck )
    static cCars := '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%'
    STATIC aBarras:={'1110100010101110',;
                     '1011100010101110',;
                     '1110111000101010',;
                     '1010001110101110',;
                     '1110100011101010',;
                     '1011100011101010',;
                     '1010001011101110',;
                     '1110100010111010',;
                     '1011100010111010',;
                     '1010001110111010',;
                     '1110101000101110',;
                     '1011101000101110',;
                     '1110111010001010',;
                     '1010111000101110',;
                     '1110101110001010',;//E
                     '1011101110001010',;
                     '1010100011101110',;
                     '1110101000111010',;
                     '1011101000111010',;
                     '1010111000111010',;
                     '1110101010001110',; //K
                     '1011101010001110',;
                     '1110111010100010',;
                     '1010111010001110',;
                     '1110101110100010',;
                     '1011101110100010',;//p
                     '1010101110001110',;
                     '1110101011100010',;
                     '1011101011100010',;
                     '1010111011100010',;
                     '1110001010101110',;
                     '1000111010101110',;
                     '1110001110101010',;
                     '1000101110101110',;
                     '1110001011101010',;
                     '1000111011101010',;//Z
                     '1000101011101110',;
                     '1110001010111010',;
                     '1000111010111010',; // ' '
                     '1000101110111010',;
                     '1000100010100010',;
                     '1000100010100010',;
                     '1000101000100010',;
                     '1010001000100010'}

    local cCar,m, n, n1,n2, cBarra := '',  nCheck := 0

    default lCheck := .f.
    cCode := upper(cCode)
    if len(cCode )>32
        cCode := left(cCode,32)
    end
    cCode := '*'+cCode+'*'
    for n:= 1 to len( cCode )
        cCar := substr( cCode,n,1)
        m:=at( cCar, cCars )
        if n>0 // otros caracteres se ignoran :-))
            cBarra := cBarra + aBarras[m]
            nCheck += (m-1)
        end
    next

   if lCheck
    cBarra+= aBarras[nCheck%43 +1]
   end
return cBarra

Code: Select all  Expand view
CODE128.PRG
===========

static aCode :={"212222",;
                   "222122",;
                   "222221",;
                   "121223",;
                   "121322",;
                   "131222",;
                   "122213",;
                   "122312",;
                   "132212",;
                   "221213",;
                   "221312",;
                   "231212",;
                   "112232",;
                   "122132",;
                   "122231",;
                   "113222",;
                   "123122",;
                   "123221",;
                   "223211",;
                   "221132",;
                   "221231",;
                   "213212",;
                   "223112",;
                   "312131",;
                   "311222",;
                   "321122",;
                   "321221",;
                   "312212",;
                   "322112",;
                   "322211",;
                   "212123",;
                   "212321",;
                   "232121",;
                   "111323",;
                   "131123",;
                   "131321",;
                   "112313",;
                   "132113",;
                   "132311",;
                   "211313",;
                   "231113",;
                   "231311",;
                   "112133",;
                   "112331",;
                   "132131",;
                   "113123",;
                   "113321",;
                   "133121",;
                   "313121",;
                   "211331",;
                   "231131",;
                   "213113",;
                   "213311",;
                   "213131",;
                   "311123",;
                   "311321",;
                   "331121",;
                   "312113",;
                   "312311",;
                   "332111",;
                   "314111",;
                   "221411",;
                   "431111",;
                   "111224",;
                   "111422",;
                   "121124",;
                   "121421",;
                   "141122",;
                   "141221",;
                   "112214",;
                   "112412",;
                   "122114",;
                   "122411",;
                   "142112",;
                   "142211",;
                   "241211",;
                   "221114",;
                   "213111",;
                   "241112",;
                   "134111",;
                   "111242",;
                   "121142",;
                   "121241",;
                   "114212",;
                   "124112",;
                   "124211",;
                   "411212",;
                   "421112",;
                   "421211",;
                   "212141",;
                   "214121",;
                   "412121",;
                   "111143",;
                   "111341",;
                   "131141",;
                   "114113",;
                   "114311",;
                   "411113",;
                   "411311",;
                   "113141",;
                   "114131",;
                   "311141",;
                   "411131",;
                   "211412",;
                   "211214",;
                   "211232",;
                   "2331112"}


function _code128(cCode,cMode)

    local nSum:=0, cBarra, cCar
    local cTemp, n, nCAr, nCount:=0
    local lCodeC := .f. ,lCodeA:= .f.


    // control de errores
    if valtype(cCode) !='C'
        alert('Barcode c128 required a Character value. ')
        return nil
    end
    if !empty(cMode)
        if valtype(cMode) = 'C' .and. Upper(cMode) $ 'ABC'
            cMode := Upper(cMode)
        else
            alert('Code 128 Modes are A,B o C. Character values.')
        end
    end
    if empty(cMode) // modo variable
        // an lisis de tipo  de c¢digo...
        if str(val(cCode),len(cCode)) = cCode // s¢lo n£meros
            lCodeC := .t.
            cTemp  := aCode[106]
            nSum   := 105
        else
            for n:=1 to len(cCode)
                nCount += if(substr(cCode,n,1) > 31,1,0) // no cars. de control
            end
            if nCount < len(cCode) / 2
                lCodeA := .t.
                cTemp := aCode[104]
                nSum := 103
            else
                cTemp := aCode[105]
                nSum := 104
            end
        end
    else
        if cMode == 'C'
            lCodeC := .t.
            cTemp := aCode[106]
            nSum := 105
        elseif cMode == 'A'
            lCodeA := .t.
            cTemp := aCode[104]
            nSum := 103
        else
            cTemp := aCode[105]
            nSum := 104
        end
    end

    nCount := 0 // caracter registrado
    for n := 1 to len(cCode)
        nCount ++
        cCar := substr(cCode,n,1)
        if lCodeC
            if len(cCode) = n  // ultimo caracter
                CTemp += aCode[101] // SHIFT Code B
                nCar := asc(cCar) - 31
            else
                nCar := Val(substr(cCode,n,2))+1
                n++
            end
        elseif lCodeA
            if cCar> '_' // Shift Code B
                cTemp += aCode[101]
                nCar := asc(cCar)-31
            elseif cCar <= ' '
                nCar := asc(cCar)+64
            else
                nCar := asc(cCar)-31
            endif
        else // code B standard
            if cCar <= ' ' // shift code A
                cTemp += aCode[102]
                nCar := asc(cCar)+64
            else
                nCar := asc(cCar)-31
            end
        endif
        nSum += (nCar-1) * nCount
        cTemp := cTemp + aCode[nCar]
    next
    nSum := nSum%103 + 1
    cTemp := cTemp + aCode[ nSum ] + aCode[107]
    cBarra := ''
    for n := 1 to len(cTemp) step 2
        cBarra += replicate('1',val(substr(cTemp,n,1)))
        cBarra += replicate('0',val(substr(cTemp,n+1,1)))
    next
return cBarra

Code: Select all  Expand view
EAN13.PRG
=========
// genera codigo ean13
static derecha:=[1110010110011011011001000010101110010011101010000100010010010001110100]
static izda1:=  [0001101001100100100110111101010001101100010101111011101101101110001011]
static izda2:=  [0100111011001100110110100001001110101110010000101001000100010010010111]
static primero:=[ooooooooeoeeooeeoeooeeeooeooeeoeeooeoeeeoooeoeoeoeoeeooeeoeo]
#include "common.ch"

function _ean13( cCode )
   local l,s1,s2,controln,ac,cad,cadena,cadena2, n1, n2, NUmero
   local Izda, Dcha, String, Mascara, k  ,n
   k:=left(alltrim(cCode)+'000000000000',12)     // padding with '0'
   // calculo del digito de control
   k:=k+EAN13_CHECK(k)                           // Chaeck Digit en EAN13
   // preparacion de la cadena de impresion
   cadena:=[]
   dcha:=SUBSTR(K,8,6)
   izda:=substr(k,2,6)
   mascara:=substr(primero,(val(substr(k,1,1))*6)+1,6)
   *  ? mascara
   // barra de delimitacion
   cadena:=[101]
   // parte izda
   for n=1 to 6
      numero:=val(substr(izda,n,1))
      if substr(mascara,n,1)=[o]
         string:=substr(izda1,numero*7+1,7)
      else
         string:=substr(izda2,numero*7+1,7)
      end
      *  ? strzero(numero,1)+[->]+string
      cadena:=cadena+string

   next
   cadena:=cadena+[01010]
   // LADO DERECHO
   for n=1 to 6
      numero:=val(substr(dcha,n,1))
      string:=substr(derecha,numero*7+1,7)
      *  ? strzero(numero,1)+[->]+string
      cadena:=cadena+string
   next
   cadena:=cadena+[101]
   *  ? cadena
   *  cadena:=cadena+[101]
return Cadena

*-- FUNCTION -----------------------------------------------------------------
*       Nombre: EAN13_CHECK()          Docs: Cayetano Gomez
*  Descripcion: Ean13, check Digit
*        Autor: Cayetano Gomez
*       Creado: 9/06/97                 Actualizado: þ9/06/97
*         Hora: 11:40:36                      Hora: þ11:40:36
*    Copyright: C.G.R.
*-----------------------------------------------------------------------------
*    Argumentos: cCode
*       Retorna: nil
*   Relacionado:
*-----------------------------------------------------------------------------
FUNCTION EAN13_CHECK(cCode)
   local s1,s2,l,Control,n
   s1:=0                                         // suma de impares
   s2:=0                                         // suma de pares
   for n=1 to 6
      s1:=s1+val(substr(cCode,(n*2)-1,1))
      s2:=s2+val(substr(cCode,(n*2),1))
   next
   control:=(s2*3)+s1
   l:=10
   do while control>l
      l:=l+10
   end
   control:=l-control

RETURN sTr(control,1,0)


function _ean13BL(nLen)
   default nLen to 12
   nLen:=int(nLen/2)
return '101'+replicate('0',nLen*7)+'01010'+replicate('0',nLen*7)+'101'


function _UPC( cCode, nLen )
   local l,s1,s2,control,n,ac,cad,cadena, n1, n2, NUmero
   local Izda, Dcha, String, Mascara, k
   default nLen to 11
   default cCode to '0'
   // valid values for nLen are 11,7
   k:=left(alltrim(cCode)+'000000000000',nLen)   // padding with '0'
   // calculo del digito de control
   k=k+Upc_CHECK(cCode,nLen)                     // cCode,nLen
   nLen++
   // preparacion de la cadena de impresion
   cadena:=[]
   dcha:=Right(K,nLen/2)
   izda:=Left(k,nLen/2)
   // barra de delimitacion
   cadena:=[101]
   // parte izda
   for n=1 to len(Izda)
      numero:=val(substr(izda,n,1))
      cadena+=substr(izda1,numero*7+1,7)
   next
   cadena:=cadena+[01010]
   // LADO DERECHO
   for n=1 to len(dcha)
      numero:=val(substr(dcha,n,1))
      cadena+=substr(derecha,numero*7+1,7)
   next
   cadena:=cadena+[101]
return Cadena

function _UPCABL(cCode)
   local cadena, k
   k:=left(alltrim(cCode)+'000000000000',11)   // padding with '0'
   // calculo del digito de control
   k=k+Upc_CHECK(cCode,11)                     // cCode,nLen
   // preparacion de la cadena de impresion
   cadena:=[101]
   // parte izda
      cadena+=substr(izda1,val(left(k,1))*7+1,7)
      cadena+=replicate('0',35) // resto
   cadena:=cadena+[01010] //centro
   // LADO DERECHO
      cadena+=replicate('0',35) // resto
      cadena+=substr(derecha,val(right(k,1))*7+1,7)
   cadena:=cadena+[101]
return Cadena

*-- FUNCTION -----------------------------------------------------------------
*       Nombre: Upc_CHECK()            Docs: Cayetano Gomez
*  Descripcion: ChechDigit del UPC
*        Autor: Cayetano Gomez
*       Creado: 9/06/97                 Actualizado: þ9/06/97
*         Hora: 11:47:09                      Hora: þ11:47:09
*    Copyright: C.G.R.
*-----------------------------------------------------------------------------
*    Argumentos: cCode
*             : nLen, Numero de digitoss ( 11 o 7)
*       Retorna: Cadena
*   Relacionado:
*-----------------------------------------------------------------------------
Function Upc_CHECK(cCode,nLen)
   local s1,s2,n,l,control
   s1:=0                                         // suma de impares
   s2:=0                                         // suma de pares
   for n=1 to nLen step 2
      s1:=s1+val(substr(cCode,n,1))
      s2:=s2+val(substr(cCode,n+1,1))
   next
   control:=(s1*3)+s2
   l:=10
   do while control>l
      l:=l+10
   end
   control:=l-control

   return str(Control,1,0)

// suplemento de 5 digitos
function _Sup5(cCode)
   local l, k, control, n, cBarras := '1011',nCar
   static parity:=[eeoooeoeooeooeoeoooeoeeooooeeooooeeoeoeooeooeooeoe]
   k:=left(alltrim(cCode)+'00000',5)             // padding with '0'
   control := right( str( val(substr(k,1,1))*3 + val(substr(k,3,1))*3 ;
      + val(substr(k,5,1))*3 + val(substr(k,2,1))*9+;
      val(substr(k,4,1))*9,5,0 ),1)
   control:=substr(primero,val(control)*6+2,5)
   for n:=1 to 5
      nCar:=val(substr(k,n,1))
      if substr(control,n,1)='o'
         cBarras+=substr(Izda2,nCar*7+1,7)
      else
         cBarras+=substr(Izda1,nCar*7+1,7)
      end
      if n<5
         cBarras+='01'
      end
   next
return cBarras

Code: Select all  Expand view
GO_CODE.PRG
===========
// imprime un codigo

#include 'FiveWin.ch'

function go_code( cBarra, nx,ny,oPrint,lHoRz, nColor, nWidth, nLen)
    local n, oBr
    if empty(nColor)
        nColor := CLR_BLACK
    end
    default lHorz := .t.

    default nWidth := 0.025 // 1/3 M/mm

    default nLen := 1.5 // Cmm.

    define brush oBr color nColor

    //    Width of Bar
    if !lHorz
        nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nWidth :=round  ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end
    // Len of bar
    if lHorz
        nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
    else
       nLen :=round  ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
    end

    for n:=1 to len(cBarra)
        if substr(cBarra,n,1) ='1'
            if lHorz
                oPrint:fillRect({nx,ny,nx+nLen,(ny+=nWidth)},oBr)
            else
                oPrint:fillRect({nx,ny,(nx+=nWidth),ny+nLen},oBr)
            end
          else
          if lHorz
            ny+=nWidth
            else
            nx += nWidth
           end
        end
    next

    oBr:end()
return nil

Code: Select all  Expand view
INT25.PRG
=========
// interleave 2 of 5
// matrix 2 of 5

#include "common.ch"

static aBar:={"00110","10001",'01001','11000','00101','10100','01100',;
              '00011','10010','01010'}
static cStart:='0000'
static cStop:='100'
static cMtSt:='10000' // matrix start/stop
static cInStart := '110' // industrial 2 of 5 start
static cInStop := '101' // industrial 2 of 5 stop

function _int25(cCode,lMode)
    local n,cBar:='', cIz:='',cDer:='',nLen:=0,nCheck:=0,cBarra:=''
    local m

    default lMode to .f.
    cCode:=trans(cCode,'@9') // elimina caracteres

    if (nLen%2=1.and.!lMode)
        nLen++
        cCode+='0'
    end
    if lMode
        for n:=1 to len(cCode) step 2
            nCheck+=val(substr(cCode,n,1))*3+val(substr(cCode,n+1,1))
        next
        cCode += right(str(nCheck,10,0),1)
    end

    nLen:=len(cCode)
    cBarra:= cStart
    // preencoding .. interlaving

    for n:=1 to nLen step 2
        cIz:=aBar[val(substr(cCode,n,1))+1]
        cDer:=aBar[val(substr(cCode,n+1,1))+1]
        for m:=1 to 5
            cBarra+=substr(cIz,m,1)+substr(cDer,m,1)
        next
    next
    cBarra+=cStop
    for n:=1 to len(cBarra) step 2
        if substr(cBarra,n,1)='1'
            cBar+='111'
        else
            cBar+='1'
        end
        if substr(cBarra,n+1,1)='1'
            cBar+='000'
        else
            cBar+='0'
        end
    next
return cBar

function _MAT25(cCode,lCheck)
    local cBar:='',cBarra:='', nCheck,n
    default lCheck to .f.
    cCode:=trans(cCode,'@9') // only digits
    if lCheck
        for n:=1 to len(cCode) step 2
            nCheck+=val(substr(cCode,n,1))*3+val(substr(cCode,n+1,1))
        next
        cCode += right(str(nCheck,10,0),1)
    end
    cBar:=cMtSt
    for n:=1 to len(cCode)
        cBar+=aBar[val(substr(cCode,n,1))+1]+'0'
    next
    cBar+=cMtSt
    for n:=1 to len(cBar) step 2
        if substr(cBar,n,1)='1'
            cBarra+='111'
        else
            cBarra+='1'
        end
        if substr(cBar,n+1,1)='1'
            cBarra+='000'
        else
            cBarra+='0'
        end
    next
return cBarra

function _Ind25(cCode,lCheck)
    local cBar:='',cBarra:='', nCheck,n
    default lCheck to .f.
    cCode:=trans(cCode,'@9') // only digits
    if lCheck
        for n:=1 to len(cCode) step 2
            nCheck+=val(substr(cCode,n,1))*3+val(substr(cCode,n+1,1))
        next
        cCode += right(str(nCheck,10,0),1)
    end
    cBar:=cInStart
    for n:=1 to len(cCode)
        cBar+=aBar[val(substr(cCode,n,1))+1]+'0'
    next
    cBar+=cInStop
    for n:=1 to len(cBar)
        if substr(cBar,n,1)='1'
            cBarra+='1110'
        else
            cBarra+='10'
        end
    next
return cBarra
 
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1048
Joined: Mon Oct 10, 2005 2:38 pm

Re: Impresión de Códigos de Barra

Postby leandro » Fri May 01, 2015 6:58 pm

Amigo gracias por responder...

Voy a intentar y cualquier cosa te comento.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1480
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Impresión de Códigos de Barra

Postby leandro » Fri May 29, 2015 5:27 pm

FiveWiDi Muchas Gracias por Responder....

Seguí tus instrucciones y logre compilar los prg y crear el ejecutable. Pero para ser sinceros, no se como enviar la imagen o el codigo a la impresora, ya que en fwppc, lo debo hacer mediante bluetooth.

¿Serias tan amable de indicarme como hacerlo?

Este es el codigo que tengo para el envio de la impresion mediante bluetoot.

Code: Select all  Expand view

***********************************************
*Procesa la Impresión del reporte por bluetooth
***********************************************
function SendText()

   local hOut:= CreateFile( "COM6:",; // change the number as needed
                             GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
   local n:=1
   Local cStrip:=""

   cStrip += "********************************"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "CIUDADELA LA BENDICION"+CRLF
   cStrip += "INFORME TOMA DE LECTURA Y VISITA"+CRLF
   cStrip += "DE VERIFICACION"+ CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "********************************"+CRLF+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "DATOS DEL LOTE"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "MANZANA: "+transform(vMan,"999")+" LOTE: "+transform(vLot,"99")+CRLF
   cStrip += "CEDULA:  "+alltrim(vTer)+CRLF
   cStrip += "NOMBRE:  "+subs(vNom,1,25)+CRLF+CRLF
   cStrip += "********************************"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "INFORMACION DE LA LECTURA"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "FUNCIONARIO ENCARGADO"+CRLF
   cStrip += "NOMBRE:  "+vUsu+" -"+subs(vNUs,1,19)+CRLF
   cStrip += "SERIAL CONTADOR: "+alltrim(vSer)+CRLF
   cStrip += "FECHA LECTURA: "+dtoc(vFec)+CRLF
   cStrip += "LECTURA: "+alltrim(str(vLec))+CRLF
   cStrip += "REGISTO VERIFICACION: HABITADO"+CRLF
   if !Empty(vObs)
     cStrip += ""+CRLF
     cStrip += CHR(27)+CHR(33)+CHR(25)
     cStrip += "OBSERVACIONES"+CRLF
     cStrip += CHR(27)+CHR(33)+CHR(4)
     cStrip += subs(vObs,1,35)+CRLF
   endif
   cStrip += "********************************"+CRLF
   cStrip += CRLF + CRLF + CRLF +CHR(27)+"J"

   for n = 1 to Len( cStrip )
      WriteByte( hOut, Asc( SubStr( cStrip, n, 1 ) ) )
   next

   CloseHandle( hOut )

return nil
 
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1480
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Impresión de Códigos de Barra

Postby Antonio Linares » Mon Jun 01, 2015 8:11 am

Leandro,

En la carpeta samples de FWPPC tienes el ejemplo bluetoth.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Impresión de Códigos de Barra

Postby leandro » Mon Jun 01, 2015 11:48 am

Antonio buenos días...

Como te habia comentando ya logre enviar la impresión por bluetooth, lo que no logro hacer es imprimir códigos de barra.

Ya compile a clase de cayetano pero no se enviarla a la impresora; intente de la siguiente manera:

Code: Select all  Expand view
***********************************************
*Procesa la Impresión del reporte por bluetooth
***********************************************
function SendText()

   local hOut:= CreateFile( "COM6:",; // change the number as needed
                             GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
   local n:=1
   Local cStrip:=""
   Local barra:=""

   barra:=_Code3_9("prueba",.f.)
   //msginfo(valtype(barra))
   //msginfo(barra)

   cStrip += "********************************"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "CIUDADELA LA BENDICION"+CRLF
   cStrip += "INFORME TOMA DE LECTURA Y VISITA"+CRLF
   cStrip += "DE VERIFICACION"+ CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "********************************"+CRLF+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "DATOS DEL LOTE"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "MANZANA: "+transform(vMan,"999")+" LOTE: "+transform(vLot,"99")+CRLF
   cStrip += "CEDULA:  "+alltrim(vTer)+CRLF
   cStrip += "NOMBRE:  "+subs(vNom,1,25)+CRLF+CRLF
   cStrip += "********************************"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(25)
   cStrip += "INFORMACION DE LA LECTURA"+CRLF
   cStrip += CHR(27)+CHR(33)+CHR(4)
   cStrip += "FUNCIONARIO ENCARGADO"+CRLF
   cStrip += "NOMBRE:  "+vUsu+" -"+subs(vNUs,1,19)+CRLF
   cStrip += "SERIAL CONTADOR: "+alltrim(vSer)+CRLF
   cStrip += "FECHA LECTURA: "+dtoc(vFec)+CRLF
   cStrip += "LECTURA: "+alltrim(str(vLec))+CRLF
   cStrip += "REGISTO VERIFICACION: HABITADO"+CRLF
   if !Empty(vObs)
     cStrip += ""+CRLF
     cStrip += CHR(27)+CHR(33)+CHR(25)
     cStrip += "OBSERVACIONES"+CRLF
     cStrip += CHR(27)+CHR(33)+CHR(4)
     cStrip += subs(vObs,1,35)+CRLF
   endif
   cStrip += "********************************"+CRLF
   cStrip += barra +CRLF //Lo intente asi....

   for n = 1 to Len( cStrip )
      WriteByte( hOut, Asc( SubStr( cStrip, n, 1 ) ) )
   next

   CloseHandle( hOut )

return nil

Pero me imprime ceros y unos .

Que me hace falta?
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1480
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 4 guests