[comp.sys.ibm.pc] How come I can't send ^Z through LPT1: ?

kellow@ndcheg.cheg.nd.edu (John Kellow) (03/24/90)

I've come across an unexpected problem.  I wrote a program on a Sun
that would print a color image on the inkjet printer connected to my
PC, so the output file is basically binary image data with some escape
sequences thrown in.  I transferred the output over to the PC and then
tried to print it using print (i.e. print foo.bar).  The first few
lines printed fine, then it stopped.  I tried 'copy foo.bar prn:' (and
lpt1:), and it did the same thing.   After spending a lot of time
going through hex dumps, I realized things were getting messed up
where there was a ^Z character.  When I changed it to something
else, then the file printed fine.  But I shouldn't have to do this -
if the data happens to be a ^Z, then its a ^Z.  So how can I properly
send a binary file to the printer?

As far as I can tell, its not the printer, its DOS.  I tried this
simple test: from basica I type 'lprint "abc"chr$(26)"def"' and I get on
the printer "abcdef", but when I put the same thing in a file and try
to print it from DOS I just get "abc". I thought ^Z meaning end of
file went out with CP/M.

If anybody has any suggestions or knows what I'm doing wrong, please
let me know.  If anyone posts a response, I'd also appreciate it if
you could mail be a copy - our news system has been having a lot of
problems lately and I don't want to miss anything.  Thanks.


John Kellow
kellow@ndcheg.cheg.nd.edu

jcb2647@cec1.wustl.edu (James Christopher Beard) (03/24/90)

Assuming that the file you want to send to the printer is called
stuff, try the following:

   COPY /B STUFF PRN

(It may be that the /B needs to go at the end instead.)  I think the
problem is that DOS presumes that LPT1 (alias PRN) is a text device,
so it should terminate output to it when it sees ^Z.  The binary (/B)
switch tells it to quit meddling.  By the way, I think the ":" after
PRN should not be used.

James Beard (beard@wuibc2.wustl.edu)

billb@crpmks.UUCP (Bill Bochnik ) (03/27/90)

In article <1174@ndcheg.cheg.nd.edu> kellow@ndcheg.cheg.nd.edu (John Kellow) writes:
>
>I've come across an unexpected problem.  I wrote a program on a Sun
>that would print a color image on the inkjet printer connected to my
>PC, so the output file is basically binary image data with some escape
>sequences thrown in.  I transferred the output over to the PC and then
>tried to print it using print (i.e. print foo.bar).  The first few
>lines printed fine, then it stopped.  I tried 'copy foo.bar prn:' (and
>lpt1:), and it did the same thing.   After spending a lot of time
>going through hex dumps, I realized things were getting messed up
>where there was a ^Z character.  When I changed it to something
>else, then the file printed fine.  But I shouldn't have to do this -
>if the data happens to be a ^Z, then its a ^Z.  So how can I properly
>send a binary file to the printer?
>
Yes, as far as I remember, ^Z is the DOS standard end of file marker for text 
files and the ilk.  The problem is that DOS sees the eof marker and terminates 
the print or copy to printer command before it has a chance to finish.  What 
you need is to get around the eof problem.  The standard way is like this:

               COPY filename.ext LPT1: /B

The /b qualifier tells DOS to copy the file as is, until the length of the 
file signifies that we are at the end.  It copys the file as (B)inary, 
ignoring the eof marker as it goes.  This little workaround should solve your 
problem.    





I think that the switch is in the DOS manual (but who reads them anyway) but 
of course an explaination of its uses is useless at best.
Good luck.