Hello all
I need help about printing the EAN 128 barcode
Please help me
Best Regards
#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> )
// RESOLUTION IN PIXEL
PRINTER oPrn NAME "Tarja"
x := oPrn:nVertRes() / 100
PAGE
oPrn:Say( x * 08, 50 , "PRODUCT " , oFont[16],,,,0) ; oPrn:Say( x * 08, 250, UPPER(ALLTRIM(PA10->LIN1)) , oFont[16],,,,0)
oPrn:Say( x * 17, 50 , "VARIETY" , oFont[15],,,,0) ; oPrn:Say( x * 17, 250, UPPER(ALLTRIM(PA10->VARI)) , oFont[15],,,,0)
->> @ x*60,500 CODE128 "123456789012345678" MODE "A" SIZE 1.35 WIDTH 0.018 OF oPrn
ENDPAGE
ENDPRINT
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( nRow, nCol, cCode, oPrint, cMode, Color, lHorz, nWidth, nHeigth )
Mode128( Barras (cCode, cMode), nRow, nCol, oPrint, lHorz, Color, nWidth, nHeigth )
RETURN nil
//----------------------------------------------------------------------
FUNCTION Mode128( cBarra, nx,ny,oPrint,lHoRz, nColor, nWidth, nLen)
LOCAL n, oBr
DEFAULT lHorz := .t. , ;
nWidth := 0.025, ;
nLen := 1.5
IF EMPTY( nColor ) ; nColor := CLR_BLACK ; ENDIF
DEFINE BRUSH oBr COLOR nColor
IF !lHorz ; nWidth := ROUND( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
ELSE ; nWidth := ROUND( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
ENDIF
IF lHorz ; nLen := ROUND( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
ELSE ; nLen := ROUND( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
ENDIF
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)
ENDIF
ELSE
IF lHorz ; ny += nWidth
ELSE ; nx += nWidth
ENDIF
ENDIF
NEXT
oBr:End()
RETURN Nil
//----------------------------------------------------------------------
FUNCTION Barras( cCode, cMode )
LOCAL nSum := 0, cBarra, cCar, cTemp, n, nCAr, nCount:=0, lCodeC := .f. ,lCodeA:= .f.
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
ENDIF
nCount := 0
FOR n := 1 TO LEN(cCode)
nCount ++ ; cCar := SUBSTR(cCode, n, 1)
IF lCodeC
IF LEN(cCode) = n ; cTemp += aCode[101] ; nCar := ASC(cCar) - 31
ELSE ; nCar := VAL(SUBSTR(cCode, n, 2)) + 1 ; n++
ENDIF
ELSEIF lCodeA
if cCar> "_" ; cTemp += aCode[101] ; nCar := ASC(cCar) - 31
ELSEIF cCar <= " " ; nCar := ASC(cCar) + 64
ELSE ; nCar := ASC(cCar) - 31
ENDIF
ELSE
IF cCar <= " " ; cTemp += aCode[102] ; nCar := ASC(cCar) + 64
ELSE ; nCar := ASC(cCar) - 31
ENDIF
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 116 guests