TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Jim Hansen
from: Darin McBride
date: 1998-09-19 10:21:18
subject: STDPRN

JH> I have #include both stdio.h and stdlib.h.  This is the command I used:

Traditionally, the non-standard stdaux and stdprn have been in stdio, so
stdlib isn't really needed.

A quick glance in stdio shows stdin, stdout, and stderr, but not the
non-standard ones.  Outta luck there.

 JH> Any ideas what the correct constant for redirecting to the printer is?

None.  However, you can open either "PRN" or, to be complete,
"/DEV/PRN" for output, i.e.:

FILE* stdprn = fopen("/DEV/PRN", "wt");
if (NULL != stdprn)
{
   int count;
   for (count = 0; count < copies; ++count)
   {
      fprintf(stdprn, "Look, ma, I'm printing!\n");
   }

   fclose(stdprn);
}

Note that using DOS's stdprn, when you're done, you simply stop using it,
and it will be closed for you when the program terminates.  This has caused
problems with multitasking spoolers (such as OS/2(*)'s) which want the port
to be 'closed' before they put it to the printer (so they know when it's
done - they don't want the DOS program's output to intermingle with other
programs, including other DOS programs).  You probable *can* close the
printer port, but it's rare to do so - you didn't open it, so you don't
think to close it.

Since you're writing OS/2 native, you have to open it, so it's more natural
to remember to close it.  OS/2 won't actually start printing it until it's
closed (unless it is the only thing in the spooler and the user has
requested to print while spooling - which means that if you fail to close
it, it will hold up the spooler for any other program that wants to
print!).

(*) For the purposes of staying on topic, OS/2 above may be replaced with
any other multitasking, spooler-based printing system, including WinNT, and
most flavours of unix.  Note that if you want to be portable to unix, you
should use "prn" or "/dev/prn" instead of the capital
versions above.  I make them capital simply to make it stand out, but
rarely do that in code.

Good luck,


---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 396/1 622/419 632/0 371 633/260 267 270 371 634/397 635/506 728 810
SEEN-BY: 639/252 670/218
@PATH: 250/102 201 99 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.