Top Document: comp.os.msdos.programmer FAQ part 4/5 Previous Document: Next Document: See reader questions & answers on this topic! - Help others by sharing your knowledge Date: 5 Feb 2002 22:03:03 -0400 If you just fprintf(stdprn, ...), C will translate some of your control codes. The way around this is to reopen the printer in binary mode: prn = fopen("PRN", "wb"); You must use a different file handle because stdprn isn't an lvalue. By the way, in DOS 5.0 a colon must not follow PRN or LPT1. There's one special case, Ctrl-Z (ASCII 26), the DOS end-of- file character. If you try to send an ASCII 26 to your printer, DOS simply ignores it. To get around this, you need to reset the printer from "cooked" to "raw" mode. Microsoft C users must use INT 21 AH=44, "get/set device information". Turbo C and Borland C++ users can use ioctl to accomplish the same thing: ioctl(fileno(prn), 1, ioctl(fileno(prn),0) & 0xFF | 0x20, 0); An alternative approach is simply to write the printer output into a disk file, then copy the file to the printer with the /B switch. A third approach is to bypass DOS functions entirely and use the BIOS printer functions at INT 17. If you also fprintf(stdprn,...) in the same program, you'll need to use fflush() to synchronize fprintf()'s buffered output with the BIOS's unbuffered. By the way, if you've opened the printer in binary mode from a C program, remember that outgoing \n won't be translated to carriage return/line feed. Depending on your printer, you may need to send explicit \n\r sequences. User Contributions:Top Document: comp.os.msdos.programmer FAQ part 4/5 Previous Document: Next Document: Part1 - Part2 - Part3 - Part4 - Part5 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: jeffrey@carlyle.org (Jeffrey Carlyle)
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: