okay. I know that. Look.
1.
************************************
In your initialization project code, create 2 global variables and put this code below
gsPrinterName, gsMACAddress is string
2.
******************************
create window with Table_Devices (ID, Name, MAC) to list your printers and in your window End of initialization code,
call function ListDevices ()
// Android procedure
PRIVATE PROCEDURE ListDevices ()
s_ListOfDevices, sID, sName, sMAC is string
// Returns the list of devices
HourGlass (True)
s_ListOfDevices = BTListDevice (btSimpleList)
HourGlass (False)
TableDeleteAll (TABLE_Devices)
IF s_ListOfDevices <> "" THEN
// List connected devices by grabbing some information from devices and populating table rows
nRow is int = 0
FOR EACH STRING sDevice OF s_ListOfDevices SEPARATED BY CR
nRow ++
// ID, Name, MAC
sID = ExtractString (sDevice, 1)
sName = ExtractString (sDevice,
sMAC = ExtractString (sDevice, 2)
// If the specified name is Empty or Blank, redefines taking through the BTInfoDevice function.
IF sName ~ = "" THEN sName = BTInfoDevice (sID, btName)
// Fill Table with devices
TableAddLine (TABLE_Devices, sID, sName, sMAC)
END
ELSE
Info (ErrorInfo (errFullDetails))
END
3.
*****************************
Select bluetooth device on your table rows and confirm with button. (You can Save it in INI for further using)
nRow is int = TableSelect (TABLE_Devices)
INIWrite ("Printer", "Name", NoSpace (TABLE_Devices [nRow] .COL_Name), fExeDir () + "\ WMBS.INI")
INIWrite ("Printer", "MAC", NoSpace (TABLE_Devices [nRow] .COL_MAC), fExeDir () + "\ WMBS.INI")
ToastDisplay (NoSpace (TABLE_Devices [nRow] .COL_Name) + "ist richtig konfiguriert", toastShort, vaMiddle, haCenter)
4.
*******************************
After you open your application
gsPrinterName = INIRead ("Printer", "Name", "", fExeDir () + "\ WMBS.INI")
gsMACAddress = INIRead ("Printer", "MAC", "", fExeDir () + "\ WMBS.INI")
5.
*********************************
To print your document use something like this
IF SocketConnectBluetooth (gsPrinterName, "SerialPortServiceClass_UUID", gsMACAddress) = False THEN
Error ("The connection to the printer could not be established", ErrorInfo (errFullDetails))
RETURN
ELSE
HReadSeekFirst (Order_Header, Order_HeaderID, gnInvoiceNumber)
SocketChangeTransmissionMode (gsPrinterName, SocketEndTag, CRLF)
Txt is string
Txt = "Number:" + gnInvoiceNumber + CR
Txt + = "Date:" + DateToString (Order_Header.Date, "DD.MM.YYYY") + CR
Txt + = "Hour:" + TimeToString (Order_Header.Time, "HH: MM") + CR
Txt + = "Payed:" + NoSpace (NumToString (Order_Header.Customer_Anzahlung, "10.2f")) + "€" + CR
Txt + = "--------------------------------" + CR
Txt + = "Customer:" + CR
Txt + = Order_Header.Customer_Name + CR
Txt + = Order_Header.Customer_Address + CR
IF NoSpace (Order_Header.Customer_Notes) <> "" THEN
Txt + = Order_Header.Customer_Notes + CR
END
Txt + = "=================================" + CR
Txt + = "Product Name Qty. Price" + CR
Txt + = "=================================" + CR
// SocketWrite (gsPrinterName, Txt)
sDescription, sUnit, sMenge is string
nLong is int
HReadSeekFirst (Order_Details, Order_HeaderID, gnInvoiceNumber)
WHILE HFound (Order_Details)
sMenge = NumToString (Order_Details.Quantity, "5.0f")
sUnit = Order_Details.Unit
sDescription = NoSpace (Left (Order_Details.Item_Name, 19))
nLong = 25 - Length (sDescription + sUnit)
Txt + = sDescription + RepeatString ("", nLong) + "" + sUnit + "" + sMenge + CR
// SocketWrite (gsPrinterName, Txt)
HReadNext (Order_Details, Order_HeaderID)
END
Txt + = "--------------------------------" + CR
Txt + = "" + CR + CR
Txt + = TextRight ("----------------------") + CR
Txt + = TextRight ("Signature") + CR
SocketWrite (gsPrinterName, Txt)
SocketClose (gsPrinterName)
END
Chargement...