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.
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
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
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)
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
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
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
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
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
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