delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/15/17:49:21

From: Henk Uijterwaal <henk AT ripe DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Printing (IBM)
Date: Thu, 15 May 1997 17:24:08 +0200
Organization: RIPE NCC
Lines: 54
Message-ID: <337B2A98.4487EB71@ripe.net>
References: <Pine DOT D-G DOT 3 DOT 91 DOT 970512130844 DOT 24572C-100000 AT dg1>
NNTP-Posting-Host: x22.ripe.net
Mime-Version: 1.0
CC: kagel AT bloomberg DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Art S. Kagel wrote:
> On Sat, 10 May 1997, Phuah Yee Keat wrote:

> > How to print something unformatted to the printer, just simple text,
> > using DJGPP, is there any classes or libraries that I can use?

I was just about to ask the same question...
 
> Just open file "LPT1" or "PRN" in binary mode and write to it:
> 
>    PRINTER=fopen("LPT1", "wb" ); 
>    fwrite( ... );

But does this do any buffering?  If I have 2 two programs running
and both open and write to LPT at the same time, what will happen?

In the Unix version of a program, I solved this by doing

   PRINTFILE=fopen (some_random_name, "w);
   fwrite (...);
   fclose ();
   system ("lpr some_random_name");
   system ("rm some_random_name");

where tmpnam is used to get the random, unique name.  This construction
has a few more advantages.  You can easily print two copies of the
output,
you can configure the print command as you like and the print queueing
mechanism takes care of two programs trying to print at the same time.

Under DJGPP, I tried 

    system ("print prn: some_random_name");

This works, BUT some of the users claim that that print doesn't
terminate
properly and eats up a bit of memory.   After 10 or so prints, a machine
with little ram has run out of memory.

I guess that what I'm really asking is: how to print to the print 
spooler under DJGPP.  

Henk.

------------------------------------------------------------------------------
Henk Uijterwaal                      Email: henk DOT uijterwaal AT ripe DOT net
RIPE-NCC                               WWW:
http://www.ripe.net/home/henk
Kruislaan 409                        Phone: +31.20.5925022
NL 1098 SJ Amsterdam                   Fax: +31.20.5925090
The Netherlands                       Home: +31.20.6651962
------------------------------------------------------------------------------

%DCL-E-NOCFFE, unable to locate coffee - keyboard input suspended.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019