Board index » delphi » Send string to parallel port printer ?

Send string to parallel port printer ?

Use AssignPrn() to do this... And then you can use the Printer port
LPT1 as a text device...  A bit like a text file...

Paul Gent

Quote
On Sun, 19 Dec 1999 17:56:39 +1300, J Preou <jpr...@ihug.co.nz> wrote:
>Hi there,
>how might I send a single string to a printer setup on LPT1 as
>generic/text only ?
>cheers.

> Jeff
>       jpr...@ihug.co.nz
>       ICQ     #33053467
>       http://homepages.ihug.co.nz/~jpreou/index.htm
>       Hamilton, New Zealand

 

Re:Send string to parallel port printer ?


Quote
J Preou <jpr...@ihug.co.nz> wrote in message

news:q9po5s0vhu9l89ecfgda406vfa2tfmgvuo@4ax.com...

Quote
> Hi there,
> how might I send a single string to a printer setup on LPT1 as
> generic/text only ?
> cheers.

Simple

COPY something LPT1. Where something is TEXT. You can do it from your
application.

Mirko

Re:Send string to parallel port printer ?


Quote
J Preou wrote:
> On Sun, 19 Dec 1999 21:14:14 GMT, p...@nospam.ie wrote:

> In my test app I do this

>   const CRLF = #13 + #12;

Hi

This probably won't help your problem much but if you wanted CR followed by
a line feed it should be CRLF = #13+#10, Character 12 is a form feed.

cheers
Handy

Re:Send string to parallel port printer ?


On Tue, 21 Dec 1999 17:19:43 +1300, J Preou <jpr...@ihug.co.nz>
waffled on about something:

Quote
>On Sun, 19 Dec 1999 23:58:30 +0100, "Mirko" <mi...@elab.tmf.bg.ac.yu>
>wrote:

>>J Preou <jpr...@ihug.co.nz> wrote in message
>>news:q9po5s0vhu9l89ecfgda406vfa2tfmgvuo@4ax.com...
>>> Hi there,
>>> how might I send a single string to a printer setup on LPT1 as
>>> generic/text only ?
>>> cheers.

>>Simple

>>COPY something LPT1. Where something is TEXT. You can do it from your
>>application.

>>Mirko

>This didn't work for me - the copy function is used to return a
>substring from a string (according to help), so how can I use it to
>send to LPT1 as you would at a DOS command line ?

I think he was talking about the dos command.
Why, I don't know!
Sorry I can't explain how to print, because I have never had to do it,
and my printer is in bits at the moment, so I can't even have a play!

Dodgy.

Re:Send string to parallel port printer ?


may i ask you how did you solve it???
i had the same problem and i've been trying something like:

  Escape(printer.handle,PASSTHROUGH,0,@MYPassThroughData,nil);

but it doesn't work on [esc] chars!

Quote
J Preou wrote:

> On Sun, 19 Dec 1999 17:56:39 +1300, J Preou <jpr...@ihug.co.nz> wrote:

> >how might I send a single string to a printer setup on LPT1 as
> >generic/text only ?

> I have now solved the problem of sending a string to my printer, only
> to be faced with a second problem - isn't that always the case !!?
> If my printer is on, online, and papered-up (!) then no problem - if,
> however, there is any sort of problem that stops the printer from
> receiving the data then my program simply freezes whilst it keeps
> trying.  So...how do I interrogate the printer to check it is ok, or
> implement a trap so that my program doesn't freeze : or perhaps return
> control after a pre-defined period of time.  I have tried IOResult but
> that doesn't work as it checks the Rewrite command and not the
> Writeln.  I really need to be able to ask the printer if it is ok...
> help (again...please !)

>  Jeff
>        jpr...@ihug.co.nz
>        ICQ     #33053467
>        http://homepages.ihug.co.nz/~jpreou/index.htm
>        Hamilton, New Zealand

Re:Send string to parallel port printer ?


Open a text (or other) file to the printer name, e.g.

var    thePrinter : TextFile;

. . .
AssignFile (thePrinter, '\\T293C5QX\HP LJ 4');
Rewrite (thePrinter);
Writeln (thePrinter, yourText);
CloseFile (thePrinter);
. . .

The last parameter of AssignFile is the UNC name of the printer - see the
contents of "Print to the following port" on the Details tab of the
printer's property sheet. (I don't currently have a local printer attached.
For a local printer you can probably use the port, e.g. 'LPT1:'. Does
somebody know?)

Quote
"J Preou" <jpr...@ihug.co.nz> wrote in message

news:q9po5s0vhu9l89ecfgda406vfa2tfmgvuo@4ax.com...
Quote
> Hi there,
> how might I send a single string to a printer setup on LPT1 as
> generic/text only ?
> cheers.

>  Jeff
>        jpr...@ihug.co.nz
>        ICQ     #33053467
>        http://homepages.ihug.co.nz/~jpreou/index.htm
>        Hamilton, New Zealand

Re:Send string to parallel port printer ?


Quote
J Preou wrote:
> On Sun, 19 Dec 1999 17:56:39 +1300, J Preou <jpr...@ihug.co.nz> wrote:

> >how might I send a single string to a printer setup on LPT1 as
> >generic/text only ?

> I have now solved the problem of sending a string to my printer, only
> to be faced with a second problem - isn't that always the case !!?
> If my printer is on, online, and papered-up (!) then no problem - if,
> however, there is any sort of problem that stops the printer from
> receiving the data then my program simply freezes whilst it keeps
> trying.  So...how do I interrogate the printer to check it is ok, or
> implement a trap so that my program doesn't freeze : or perhaps return
> control after a pre-defined period of time.  I have tried IOResult but
> that doesn't work as it checks the Rewrite command and not the
> Writeln.  I really need to be able to ask the printer if it is ok...
> help (again...please !)

To trap the error you may want to use the standard try/except/end method
(if it works ;) ).

In "old" Dos days, there was a interrupt function what checked the status
of the port. Maybe it can be made run on Windows too.

Urmas

Re:Send string to parallel port printer ?


Is there some compelling reason why you want to bypass Windows extensive
support for printers and print spooling?

Quote
"J Preou" <jpr...@ihug.co.nz> wrote in message

news:825e6sc5pnsfergqscvjtclulmhan0msh7@4ax.com...
Quote
> On Fri, 24 Dec 1999 10:07:44 +0200, Urmas <Urmas.P...@rlk.ee> wrote:

> >To trap the error you may want to use the standard try/except/end method
> >(if it works ;) ).

> Any idea how ?  No exception is generated...the program just
> hangs...so what can I trap ?  I can't even implement a timer (unless
> someone can show me how - when the program hangs everything stops
> working).  That is why I really need to be able to check the printer
> status - I don't want the customer getting the arsehole because I rely
> on 'blind luck' that the printer will always be on...!

>  Jeff
>        jpr...@ihug.co.nz
>        ICQ     #33053467
>        http://homepages.ihug.co.nz/~jpreou/index.htm
>        Hamilton, New Zealand

Other Threads