Printing via Blooth

Post Reply
cllow208
Posts: 20
Joined: Fri Apr 27, 2012 7:53 am

Printing via Blooth

Post by cllow208 »

Can somebody kindly help please? :)

I need to print to a BLUE Tooth port COM6, using the posted examples , I got error messages on defination
GENERIC_WRITE, which header files i need for definations: GENERIC_WRITE, OPEN_EXISTING and FILE_ATTRIBUTE_NORMAL ??

Thanks again...

best regards,
CL Low


hOut := CreateFile( "COM6:",GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
IF hOut==-1
MsgStop("Port Impression non trouvé, Impression Impossible")
ELSE
FOR i = 1 TO Len( cText )
//WriteByte( hOut, Asc(SubStr( cText, i, 1 ) ) )
WriteByte( hOut, SubStr( cText, i, 1 ) )
SysRefresh()
NEXT

CloseHandle( hOut )
MsgStop("Port send successfully")
endif
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Printing via Blooth

Post by Jeff Barnes »

This is what I use to print to a POS bluetooth printer:

Code: Select all


#define GENERIC_WRITE         0x40000000
#define OPEN_EXISTING         3
#define FILE_ATTRIBUTE_NORMAL 0x00000080

Function BluePrint()
    Local cPrnCom:="COM6:"
    Local i, hOut, cStrip:=""
    cStrip += "This is a test"+ CRLF + CRLF 
    cStrip += "*****End of Report****"+CRLF
    cStrip += CRLF + CRLF + CRLF +CHR(27)+"J"   

    hOut := CreateFile( cPrnCom,GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
    IF hOut==-1
       MsgStop("xxxxxx error Port not found")
        ELSE
       FOR i = 1 TO Len( cStrip )
          WriteByte( hOut, Asc(SubStr( cStrip, i, 1 ) ) )
       NEXT
      syswait(2)
      CloseHandle( hOut )
    ENDIF
Return Nil
 
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
cllow208
Posts: 20
Joined: Fri Apr 27, 2012 7:53 am

Re: Printing via Bluetooth

Post by cllow208 »

Hi Jeff,

Thank you very much. It works.

Thanks again..
Post Reply