Page 1 of 1

Printing via Blooth

PostPosted: Fri May 04, 2012 10:04 am
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

Re: Printing via Blooth

PostPosted: Fri May 25, 2012 12:53 am
by Jeff Barnes
This is what I use to print to a POS bluetooth printer:

Code: Select all  Expand view


#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
 

Re: Printing via Bluetooth

PostPosted: Mon May 28, 2012 3:14 am
by cllow208
Hi Jeff,

Thank you very much. It works.

Thanks again..