Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anybody knows the code to PRINT TO LPT1

Status
Not open for further replies.

JuanjoZun

Programmer
Jul 20, 2002
82
MX
Hello...

I just forget the Code to Print to LPT1 Port... you know,
I need to send text to a printer connected in LPT1 port...

Please Help me.


Thanks
Juanjo



Follow the dark side, so you can reach the light.
 
You can actually worry about sending it to the port but I would recommend against this unless you have good reason. It's a lot simpler to simply send it to a text file opened to LPT1. That makes it a lot easier for network redirection and the like.
 
If you include the unit printer, there is a predefined text file variable lst you can use:
Code:
USES printer;
BEGIN
  write(lst,'Hello printer!#12'); {Send a string followed by a FF}
END.
If you want to write to a specific port, you can try this:
Code:
VAR prn : text;
BEGIN
  assign(prn,'LPT1'); {Other ports may be LPT2, ..., COM1, COM2, ...}
  rewrite(prn);
  write(prn,'Hello printer!#12'); {Send a string followed by a FF}
  close(prn);
END.

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
Thank you very much!! It's the thing I wanted to know...

Thanks

Regards
Juanjo

Follow the dark side, so you can reach the light.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top