Harbour for Beginner
Je viens de trouver un chouette document "Harbour for Beginner" d'alexender Kresin (anglais) où il aborde des points très intéressantes:
- Some language extensions
- Classes and objects
- Lang API (the language of the program)
- Codepage API
- Working with hrb - files
- The built-in C
- Hash arrays
- Regular expressions
- INET subsystem
- Multithreading
- Miscellaneous functions
C'est que la Zebra n'apprécie pas l'ANSI, elle fait sauter tous les accentués si le flux est ANSI mais en UTF-8 c'est impeccable.
Création d'un fichier ZPL et envoi Sur Zebra
Voici un petit programme clipper compilé avec Harbour Project qui crée un fichier ZPL puis l'envoi sur l'imprimante Zebra LP 2824 nommée ZEBRA_RAW (voyez l'article "Imprimante Zebra USB, ZPL et Spooler Windows - Sacré Windows!!!").
Pas le code le plus pure... mais le vilain proto marche très bien :-)
&& #include "mediator.ch" Mediator - PostgreSql middleware
#include "fileio.ch"
LOCAL hDst := NIL
LOCAL sOutFilename := 'demo.zpl'
LOCAL sPrinterName := 'ZEBRA_RAW'
&& Mediator - PostgreSql middleware
&& request medntx
REQUEST HB_CODEPAGE_FRWIN
SET( _SET_CODEPAGE, "FRWIN" )
&& Mediator - PostgreSql middleware
&& RDDSETDEFAULT("MEDNTX") && set default data source to MEDNTX RDD driver
* -- initialisation
set date british
set delete on
set confirm on
set escape on
set wrap on
set epoch to 1920
? 'Create a '+sOutFilename+' file encoded with UTF-8'
&& Open Destination Filename
hDst := hb_FCreate( sOutFilename, FC_NORMAL, FO_READWRITE + FO_SHARED )
IF hDst == F_ERROR
sMsg = "Impossible de recréer FAReprint.txt!"
ALERT( HB_AnsiToOem(sMsg) ) && convert to "DOS String"
RETURN NIL
ENDIF
&& Surprenant, pas besoin de hb_StrToUtf8(), le fichier est déjà
&& encodé en UTF8! Impression sur Zebra Parfaite
cBuf = '^XA'
fwrite( hDst, cBuf + hb_eol() )
cBuf = '^FO100,50^ADN,36,20^FDxyz*é&êà*^FS'
fwrite( hDst, cBuf + hb_eol() )
cBuf = '^XZ'
fwrite( hDst, cBuf + hb_eol() )
FCLOSE( hDst )
? 'WIN_PrintFileRaw: Send ZPL to Printer '+sPrinterName
retCode = hb_ntos( WIN_PrintFileRaw( sPrinterName, (sOutFilename) ))
? "print retCode for "+sPrinterName+" = "+retCode
Ressources
Aucun commentaire:
Enregistrer un commentaire