'TCP/IP Printing
'********************************
'this explains how to connect to a printer and send raw text to the printer
'this is very useful to linux users who cant use the LPRINT command.
'********************************
DIM PrinterConnect AS LONG
DIM CRLF AS STRING
DIM CRFF AS STRING
DIM LinePrint AS STRING
CRLF$ = CHR$(13) + CHR$(10) ' end current print line and starts new line
FF$ = CHR$(12) ' end current print line and finish printing
ESC$ = CHR$(27)
CLS
PrinterConnect = _OPENCLIENT("TCP/IP:9100:***.***.***.***") 'replace astrix with your printers IP address. opens a connection to your printer
IF PrinterConnect THEN
    PRINT "[Connected to " + _CONNECTIONADDRESS(PrinterConnect) + "]"
ELSE PRINT "[Connection Failed!]"
END IF

printstring1$ = "this is a printed line" + CRLF$

PRINT
INPUT "please enter the name of the file you want to print>", FileName$
OPEN FileName$ FOR INPUT AS #1
DO
    LINE INPUT #1, LinePrint$
    PrintString$ = LinePrint$ + CRLF$
    PUT #PrinterConnect, , PrintString$:
LOOP UNTIL EOF(1)
PUT #PrinterConnect, , FF$



