From: Henk Uijterwaal 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: NNTP-Posting-Host: x22.ripe.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: kagel AT bloomberg DOT com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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.