leue@galen.steinmetz (03/08/88)
I am attempting to use the Imagewriter I connected to the printer port as a debugging tool in connection with a small application I am writing using Lightspeed C Rev 2.11. I have been successful in getting output to the printer, but cannot get the paper to advance. Here is the relevant code fragment: #include "stdio.h" . . FILE *pfile; . . pfile = fopen(".BOut", "a"); . . fprintf(pfile, "Hello, World\n"); fprintf(pfile, "This is the next line\n"); . . fclose(pfile); . . The symptoms are that all the output is printed, but each succeeding line of text overwrites the last one -- that is, the paper never advances. The standard switch settings are used on the Imagewriter, and all standard Mac applications print fine. I have tried several workarounds: * replacing the "\n" with "\012\015" * using the escape code to force one or more line feeds * turning on automatic line feed mode Nothing works. Any suggestions? -Bill Leue leue@ge-crd.arpa uunet!steinmetz!nmr!leue
tedj@hpcilzb.HP.COM (Ted Johnson) (03/11/88)
Why not just use the EchoToPrinter() function? Just type: EchoToPrinter(TRUE);\ and then do the usual: printf("\nSome stuff."); printf("\nAnother line of some more stuff."); Of course, this makes the printout go to your stdio window as well as your printer, which may not be exactly what you want... -Ted
socha@drivax.UUCP (Henri J. Socha (7-x6628)) (03/11/88)
In article <9847@steinmetz.steinmetz.UUCP> leue@galen.UUCP (Bill Leue) writes: >I have been successful in getting >output to the printer, but cannot get the paper to advance. >#include "stdio.h" >FILE *pfile; >pfile = fopen(".BOut", "a"); >fprintf(pfile, "Hello, World\n"); >fprintf(pfile, "This is the next line\n"); >fclose(pfile); >The symptoms are that all the output is printed, but each succeeding >line of text overwrites the last one -- that is, the paper never advances. > * replacing the "\n" with "\012\015" >Nothing works. Any suggestions? >-Bill Leue If I may, I've send stuff about similar problems on the net before and I even had it but in neither case was it printer related. But, the symptoms fit so: The fopen uses "a" mode. This is not BINARY ouput and should be something like "ab" (but I'm not positive about that second character my manuals and Mac are not here.) The problem that in text mode somewhere deep inside the C runtime library there is a test which goes something like (NOTE: I'm totally paraphrasing): if ((c == '\n') && !(mode && BINARY)) c = '\r' Now I may have the \n and \r backwards but I think you get the idea. The reason you see no line feeds is that the stdio library is converting those line feeds into carriage returns! This is the standard for Mac text files but not printers. So, try mode "ab" (or whatever that letter is). I hope this helps. -- UUCP:...!amdahl!drivax!socha WAT Iron'75 "Everything should be made as simple as possible but not simpler." A. Einstein