FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour SAYBARCODE algunas dudas
Posts: 1818
Joined: Wed Oct 26, 2005 02:49 PM

SAYBARCODE algunas dudas

Posted: Wed Oct 30, 2019 01:36 PM
Buenas noches para todos

Dos preguntas sobre SAYBARCODE

Primera: Cuando intento compilar este c贸digo

Code (fw): Select all Collapse
 聽 DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
聽 聽DEFINE DIALOG oDlg SIZE 600,800 PIXEL TRUEPIXEL FONT oFont ;
聽 聽 聽 TITLE "TSAYBARCODE CONTROL"

聽 聽@ 240, 40 SAY "Name 聽 聽:" GET cName 聽 聽SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
聽 聽@ 270, 40 SAY "City 聽 聽:" GET cCity 聽 聽SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
聽 聽@ 300, 40 SAY "Country :" GET cCountry SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
聽 聽@ 330, 40 SAY "Item 聽 聽:" GET cItem 聽 聽SIZE 200,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. ) ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 PICTURE "999999999999" RIGHT
聽 聽@ 聽230,450 SAYBARCODE oSay ;
聽 聽 聽 TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
聽 聽 聽 TYPE "QR-CODE" SIZE 100,100 PIXEL OF oDlg ;
聽 聽 聽 UPDATE

聽 聽ACTIVATE DIALOG oDlg CENTERED
聽 聽RELEASE FONT oFont


Me arroja el siguiente error de sintaxis

Code (fw): Select all Collapse
c:\a-inv32\prg\Diwcap01.prg(2299) Error E0030 聽Syntax error: "syntax error at '@'"
Ya fue agregada la instrucci贸n REQUEST FWZEBRA alinicio del prg.

Segunda pregunta:

Es posible utilizar SAYBARCODE desde recursos?

De antemano gracias
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 346
Joined: Mon Oct 05, 2009 03:35 PM

Re: SAYBARCODE algunas dudas

Posted: Wed Oct 30, 2019 09:11 PM
Leandro:

con una clase que encontre en el foro, genero un QR con informaci贸n (que entre mas caracteres tiene es mas grande el QR), el cual lo imprimo en el preview

pero lo simpatico de esto es que genera un archivo BMP y este puede ser puesto en unrecurso "IMAGE" y te puede ayudar a lo que necesitas.

aqui la clase:

Code (fw): Select all Collapse
#Include "FiveWin.ch"

#define CODEBAR_EAN13 聽 聽 聽 聽 聽1
#define CODEBAR_EAN8 聽 聽 聽 聽 聽 2
#define CODEBAR_UPCA 聽 聽 聽 聽 聽 3
#define CODEBAR_UPCE 聽 聽 聽 聽 聽 4
#define CODEBAR_ITF 聽 聽 聽 聽 聽 聽5
#define CODEBAR_MSI 聽 聽 聽 聽 聽 聽6
#define CODEBAR_CODABAR 聽 聽 聽 聽7
#define CODEBAR_CODE11 聽 聽 聽 聽 8
#define CODEBAR_CODE39 聽 聽 聽 聽 9
#define CODEBAR_CODE93 聽 聽 聽 聽 10
#define CODEBAR_CODE128 聽 聽 聽 聽11
#define CODEBAR_PDF417 聽 聽 聽 聽 12
#define CODEBAR_DATAMATRIX 聽 聽 13
#define CODEBAR_QRCODE 聽 聽 聽 聽 14

#define CODEBAR_TYPE 聽 聽 聽 聽 聽 1
#define CODEBAR_BLOCK 聽 聽 聽 聽 聽2

#define DEFAULT_CODEBAR 聽 聽 聽 聽CODEBAR_PDF417

//--------------------------------------

CREATE CLASS TCodeBars

聽 聽DATA aTypes HIDDEN

聽 聽DATA cCode
聽 聽DATA nFlags

聽 聽DATA hCodeBar
聽 聽DATA hData

聽 聽DATA nType, nWidth, nHeight, nWidthCode, nHeightCode

聽 聽METHOD New()
聽 聽METHOD End() 聽 聽 INLINE 聽DeleteObject( ::hCodeBar ), 聽If( ::hData != NIL, hb_zebra_destroy( ::hData ), )

聽 聽METHOD DefError( nError )
聽 聽METHOD SetCode( cCode )
聽 聽METHOD SetFlags( nFlags )
聽 聽METHOD SetType( cnType )
聽 聽METHOD Reset() 聽 INLINE ::End()
聽 聽METHOD Build()
聽 聽METHOD Rebuild() INLINE ::Reset(), ::Build()

ENDCLASS

//--------------------------------------

METHOD New( nWidth, nHeight, nWidthCode, nHeightCode, cnType, cCode, nFlags ) CLASS TCodeBars

聽 聽DEFAULT nWidth 聽 聽 聽 := 200,;
聽 聽 聽 聽 聽 聽nHeight 聽 聽 聽:= 100,;
聽 聽 聽 聽 聽 聽nWidthCode 聽 := 聽 1,;
聽 聽 聽 聽 聽 聽nHeightCode 聽:= 聽 3


聽 聽::aTypes = { { "EAN13" 聽 聽 聽, {| | hb_zebra_create_ean13( ::cCode, ::nFlags ) 聽 聽 聽} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "EAN8" 聽 聽 聽 , {| | hb_zebra_create_ean8( ::cCode, ::nFlags ) 聽 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "UPCA" 聽 聽 聽 , {| | hb_zebra_create_upca( ::cCode, ::nFlags ) 聽 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "UPCE" 聽 聽 聽 , {| | hb_zebra_create_upce( ::cCode, ::nFlags ) 聽 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "ITF" 聽 聽 聽 聽, {| | hb_zebra_create_itf( ::cCode, ::nFlags ) 聽 聽 聽 聽} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "MSI" 聽 聽 聽 聽, {| | hb_zebra_create_msi( ::cCode, ::nFlags ) 聽 聽 聽 聽} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "CODABAR" 聽 聽, {| | hb_zebra_create_codabar( ::cCode, ::nFlags ) 聽 聽} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "CODE11" 聽 聽 , {| | hb_zebra_create_code11( ::cCode, ::nFlags ) 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "CODE39" 聽 聽 , {| | hb_zebra_create_code39( ::cCode, ::nFlags ) 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "CODE93" 聽 聽 , {| | hb_zebra_create_code93( ::cCode, ::nFlags ) 聽 聽 } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "CODE128" 聽 聽, {| | hb_zebra_create_code128( ::cCode, ::nFlags ) 聽 聽} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "PDF417" 聽 聽 , {| | NIL /*hb_zebra_create_pdf417( ::cCode, ::nFlags ) 聽 聽 */} },;
聽 聽 聽 聽 聽 聽 聽 聽 { "DATAMATRIX" , {| | hb_zebra_create_datamatrix( ::cCode, ::nFlags ) } },;
聽 聽 聽 聽 聽 聽 聽 聽 { "QRCODE" 聽 聽 , {| | hb_zebra_create_qrcode( ::cCode, ::nFlags ) 聽 聽 } } }

聽 聽::nWidth 聽 聽 聽:= nWidth
聽 聽::nHeight 聽 聽 := nHeight
聽 聽::nWidthCode 聽:= nWidthCode
聽 聽::nHeightCode := nHeightCode

聽 聽::SetType( cnType )
聽 聽::SetCode( cCode )
聽 聽::SetFlags( nFlags )

Return Self

//--------------------------------------

METHOD Build() CLASS TCodeBars

聽 聽local hBmpOld
聽 聽local hDCDesk := GetDC( GetDesktopWindow() )
聽 聽local hDCMem 聽:= CreateCompatibleDC( hDCDesk )
聽 聽local hBrush 聽:= CreateSolidBrush( 0 )
聽 聽local hBack 聽 := CreateSolidBrush( CLR_WHITE )

聽 聽::hCodeBar 聽 聽:= CreateCompatibleBitMap( hDCDesk, ::nWidth, ::nHeight )
聽 聽hBmpOld 聽 聽 聽 := SelectObject( hDCMem, ::hCodeBar )

聽 聽::hData 聽 聽 聽 := Eval( ::aTypes[ ::nType ][ CODEBAR_BLOCK ] )

聽 聽::DefError()
聽 聽FillRect( hDCMem, { 0, 0, ::nHeight, ::nWidth }, hBack )
聽 聽hb_zebra_draw( ::hData, {| x, y, w, h | FillRect( hDCMem, { y, x, y + 聽h, x + w }, hBrush ) }, 0, 0, ::nWidthCode, ::nHeightCode )

聽 聽//DrawText( hDCMem, ::cCode, { ::nHeight - 15, 0, ::nHeight, ::nWidth }, 1 )

聽 聽SelectObject( hDCMem, hBmpOld )
聽 聽ReleaseDC( GetDesktopWindow(), hDCDesk )
聽 聽DeleteDC( hDCMem )
聽 聽DeleteObject( hBrush )
聽 聽DeleteObject( hBack )

Return NIL

//--------------------------------------

METHOD SetCode( cCode ) CLASS TCodeBars

聽 聽if ! Empty( cCode )
聽 聽 聽 if ValType( cCode ) != "C"
聽 聽 聽 聽 聽cCode = cValToChar( cCode )
聽 聽 聽 endif
聽 聽 聽 ::cCode = cCode
聽 聽endif

Return NIL

//--------------------------------------

METHOD SetFlags( nFlags ) CLASS TCodeBars

聽 聽::nFlags = nFlags

Return Nil

//--------------------------------------

METHOD SetType( cnType ) class TCodeBars

聽 聽local cType

聽 聽if ( ( cType := ValType( cnType ) )$"CN" )
聽 聽 聽 if cType == "N"
聽 聽 聽 聽 聽if cnType > 0 .and. cnType < 15
聽 聽 聽 聽 聽 聽 ::nType = cnType
聽 聽 聽 聽 聽endif
聽 聽 聽 else
聽 聽 聽 聽 聽::nType = AScan( ::aTypes, {| a | a[ CODEBAR_TYPE ] == Upper( cnType ) } )
聽 聽 聽 endif
聽 聽else
聽 聽 聽 ::nType = DEFAULT_CODEBAR
聽 聽endif

Return NIL

//--------------------------------------

METHOD DefError( ) CLASS TCodeBars
聽 聽local oError
聽 聽local nError := 0

聽 聽if ::hData != NIL
聽 聽 聽 nError = hb_zebra_geterror( ::hData )
聽 聽endif

聽 聽if nError != 0
聽 聽 聽 hb_zebra_destroy( ::hData )

聽 聽 聽 oError := ErrorNew()
聽 聽 聽 oError:SubSystem 聽 = "TCODEBARS"
聽 聽 聽 oError:SubCode 聽 聽 = nError
聽 聽 聽 oError:Severity 聽 聽= 2

聽 聽 聽 Eval( ErrorBlock(), oError )
聽 聽endif

Return Nil

//--------------------------------------

#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>

HB_FUNC( CREATECOMPATIBLEBITMAP ) // hDC, nWidth, nHeight
{
聽 聽hb_retnl( ( LONG ) CreateCompatibleBitmap( ( HDC ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) ) );
}

#pragma ENDDUMP

//------------------------------------------------


como lo utilizo:

Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽cCodeBar 聽:= "entre mas letras o caracteres tenga es mas grande"

聽 聽 聽 聽 聽 聽oQRCode:= TCodeBars():New( 421, 421, 10, 10, CODEBAR_QRCODE, cCodeBar )
聽 聽 聽 聽 聽 聽oQRCode:Build()
聽 聽 聽 聽 聽 聽GeneraCodigo_QR( oQRCode )


PRINTER oPrn NAME "Tarja Pallet" PREVIEW 聽
PAGE
...
...
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oPrn:SayImage(4800, 3500 , "..\QrCode.bmp",1200,1200 )
...
...
ENDPAGE
ENDPRINT


//----------------------------------------------------------------------

Function GeneraCodigo_QR( oCode )
聽 聽Local hDib

聽 聽If ( File( ..\QrCode.bmp" ), Ferase( ..\QrCode.bmp" ), )

聽 聽hDib := DibFromBitmap( oCode:hCodeBar )
聽 聽DibWrite( "..\QrCode.bmp", hDib )
聽 聽GloBalFree( hDib )

聽Return nil

//----------------------------------------------------------------------



Resultado:

1. https://i.postimg.cc/MTXXYGTS/Captura3.jpg

Espero que te oriente un poco

Saludos
SkyPe: armando.lagunas@hotmail.com

Mail: armando.lagunas@gmail.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: SAYBARCODE algunas dudas

Posted: Wed Oct 30, 2019 09:37 PM

Antes de seguir investigando, aseg煤rate que est茅s utilizando el fivewin.ch que viene con tu versi贸n de Fivewin, si, efectivamente es el fichero .ch correcto, busca el comando y comprueba que la sintaxis que has utilizado es la que aparece en el comando del fichero .ch y en el mismo orden, que algunas veces esto produce alg煤n quebradero de cabeza.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: SAYBARCODE algunas dudas

Posted: Thu Oct 31, 2019 03:03 AM
Me arroja el siguiente error de sintaxis


I tried your program here with FWH1903 and I did not get any errors
This is the exact code I used and built it with buildh.bat and also buildx.bat

Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWZEBRA

function Main()

   local oDlg, oFont, oSay, cName, cCity, cCountry, cItem

   cName    := PadR( "Antonio Linares", 20 )
   cCity    := PadR( "Marbella", 20 )
   cCountry := PadR( "Spain", 20 )
   cItem    := "123456789012"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,800 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "TSAYBARCODE CONTROL"

   @ 240, 40 SAY "Name    :" GET cName    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 270, 40 SAY "City    :" GET cCity    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 300, 40 SAY "Country :" GET cCountry SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 330, 40 SAY "Item    :" GET cItem    SIZE 200,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. ) ;
                                          PICTURE "999999999999" RIGHT
   @  230,450 SAYBARCODE oSay ;
      TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
      TYPE "QR-CODE" SIZE 100,100 PIXEL OF oDlg ;
      UPDATE

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 1818
Joined: Wed Oct 26, 2005 02:49 PM

Re: SAYBARCODE algunas dudas

Posted: Tue Nov 12, 2019 03:44 PM

Mr Nages, Gracias por responder:

Compile el ejemplo que me envi贸, lo hice con la versi贸n que estoy utilizando actualmente FWH1909, tambi茅n para pruebas hice la con FWH1903 y funciona bien.

El problema ocurre al momento que integro el c贸digo (exactamente igual), a nuestra aplicaci贸n, en ese momento es cuando sale el error de sintaxis.

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

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1818
Joined: Wed Oct 26, 2005 02:49 PM

Re: SAYBARCODE algunas dudas

Posted: Tue Nov 12, 2019 03:47 PM

Armando, gracias por responder.

Efectivamente de la forma que mencionas estoy haciendo que funcione, bajando una imagen del QR al disco y luego si mostrarla por pantalla, mientras sale una versi贸n en la que pueda dibujar el codigoQR, directamente desde recursos.

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

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: SAYBARCODE algunas dudas

Posted: Tue Nov 12, 2019 04:30 PM
El problema ocurre al momento que integro el c贸digo (exactamente igual), a nuestra aplicaci贸n, en ese momento es cuando sale el error de sintaxis.

Please ensure that you are using the correct version of "fivewin.ch", without any modifications. You should not get any syntax errors.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: SAYBARCODE algunas dudas

Posted: Tue Nov 12, 2019 04:33 PM
leandro wrote:Armando, gracias por responder.

Efectivamente de la forma que mencionas estoy haciendo que funcione, bajando una imagen del QR al disco y luego si mostrarla por pantalla, mientras sale una versi贸n en la que pueda dibujar el codigoQR, directamente desde recursos.


Hope you know that you can easily create QR code bmp with these functions:
Code (fw): Select all Collapse
hBitmap := FW_BarCodeBmp( cText, "QR", nWidth, nHeight )
FW_SaveImage( hBitmap, cBmpFile )
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion