Sub NetworkPrinter_Connected (Successful As Boolean) As ResumableSub
If Successful Then
AStreams.Initialize(NetworkPrinter.InputStream, NetworkPrinter.OutputStream, "AStreams")
End If
Return Successful
End Sub
Sub ConnectPrinters(ipAddress As String, portNo As Int, timeOut As Int, timeToConnect As Int)As ResumableSub
NetworkPrinter.Connect(ipAddress, portNo, timeOut)
Dim timeCounter As Int = 0
Dim connected As Boolean = False
Do Until timeCounter = timeToConnect Or connected = True
Sleep(1000)
connected = NetworkPrinter.Connected
timeCounter = timeCounter + 1
Log(timeCounter)
Loop
Return connected
End Sub
Sub SendToPrinter (printerOutput As String)
Wait For (ConnectPrinters("192.168.0.2", 9100, 0, 5)) Complete (connectedResult As Boolean)
If connectedResult Then
Log("Initialised")
Log(printerOutput)
AStreams.Write(printerOutput.GetBytes("UTF8"))
NetworkPrinter.Close
Else
Log("Printer not initialised")
End If
End If