Author Topic: TCP/IP Printer  (Read 4114 times)

0 Members and 1 Guest are viewing this topic.

Offline AtomicSlaughter

  • Newbie
  • Posts: 14
    • View Profile
TCP/IP Printer
« on: February 04, 2021, 02:29:52 pm »
So i wrote a program that will print a file to printer in raw text.

I needed this as the LPRINT command is unavailable on LINUX.

I hope this file is helpful to you all.

Code: QB64: [Select]
  1. DIM PrinterConnect AS LONG
  2. DIM LinePrint AS STRING
  3. CRLF$ = CHR$(13) + CHR$(10) ' end current print line and starts new line
  4. FF$ = CHR$(12) ' end current print line and finish printing
  5. ESC$ = CHR$(27)
  6. PrinterConnect = _OPENCLIENT("TCP/IP:9100:***.***.***.***") 'replace astrix with your printers IP address. opens a connection to your printer
  7. IF PrinterConnect THEN
  8.     PRINT "[Connected to " + _CONNECTIONADDRESS(PrinterConnect) + "]"
  9. ELSE PRINT "[Connection Failed!]"
  10.  
  11. printstring1$ = "this is a printed line" + CRLF$
  12.  
  13. INPUT "please enter the name of the file you want to print>", FileName$
  14. OPEN FileName$ FOR INPUT AS #1
  15.     LINE INPUT #1, LinePrint$
  16.     PrintString$ = LinePrint$ + CRLF$
  17.     PUT #PrinterConnect, , PrintString$:
  18. PUT #PrinterConnect, , FF$
* TCP-IP_Printer.bas (Filesize: 1.08 KB, Downloads: 226)
« Last Edit: February 04, 2021, 02:57:39 pm by AtomicSlaughter »

FellippeHeitor

  • Guest
Re: TCP/IP Printer
« Reply #1 on: February 04, 2021, 02:40:28 pm »
That's very useful! Thanks for sharing, this definitely needs to have a mention in the Wiki for non-Windows users.

Also, thanks @SpriggsySpriggs for pointing it out in the chat at Discord.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: TCP/IP Printer
« Reply #2 on: February 04, 2021, 03:14:56 pm »
I'll have to assume Fell checked it out on his Linux system, so it works, as advertised. This would be a great addition to the Wiki. I was thinking of how to work something similar to this into my WP, for non-Windows users. Adding this might be the ticket.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: TCP/IP Printer
« Reply #3 on: February 04, 2021, 03:45:31 pm »
I didn't test it myself, but I followed Atomic as he tested and tweaked this until it worked in this final form he published.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: TCP/IP Printer
« Reply #4 on: February 04, 2021, 06:17:38 pm »
That's very useful! Thanks for sharing, this definitely needs to have a mention in the Wiki for non-Windows users.

Also, thanks @SpriggsySpriggs for pointing it out in the chat at Discord.

No problem. Glad Atomic got to make use of something I used at work.
Shuwatch!

Offline AtomicSlaughter

  • Newbie
  • Posts: 14
    • View Profile
Re: TCP/IP Printer
« Reply #5 on: February 04, 2021, 06:25:57 pm »
Thank you for your help with this SpriggsySpriggs