![]() |
| | #1 |
| Registered User Join Date: Aug 2002
Posts: 6
| I'm using Borland C++ 4.0 and WIN98. I tried to duplicate the printer routine using Borland Turbo C++ 3.1 with no success. The test program: /* Print2 printer test */ #include <stdio.h> FILE *prnt; main() { prnt = fopen("LPT1", "w"); fprintf(prnt, "This is a PRINTER test!!!!!\n"); fclose(prnt); return(0); } I selected the Target Type as "Application.exe". And the Platform as "DOS Standard". I compiled using Project/Make all. When I tried Project/Compile, the printer would not actvate. I saved the program and closed all windows. At the MS DOS prompt, I typed; C:\bc4\bin\FileName.exe and hit Enter. The Printer activated and produced the desired output. One problem. Something in the code is causing the printer to take a long time to spit out a copy. But I can manually speed up the output by pressing the paper feed button. The printer functions normally during other operations. Anybody have a suggestion for a code modification that would speed up the printer??? Thanks for prior help and for any additional help... |
| noraa is offline | |
| | #2 |
| Registered User Join Date: Jul 2002
Posts: 945
| you are not telling the printer to spit out the finished product. if it spits it out at all without your intervention, then it's simply because it timed out waiting for more data. however i do not know the exact commands to eject a sheet, maybe a bunch of \n would do it
__________________ hello, internet! |
| moi is offline | |
| | #3 |
| Registered User Join Date: Aug 2002
Posts: 6
| I just discovered that after I compiled the test printer program and clicked on RUN, the printer activated in <Windows>. I did not have to go to the <MS DOS> prompt..... So, it appears that my original selection of the Target Type as EasyWin.EXE and Platform Type as Windows 3.x(16) prevented ANY Printer activity. Application.exe for the Target Type and DOS Standard for the Platform Window is the correct selection to activate the Printer with a C program (with Borland C++ 4.0) in Windows. The Printer is still slow. |
| noraa is offline | |
| | #4 |
| Unleashed Join Date: Sep 2001
Posts: 1,755
| You seem to be having a touch of trouble manipulating your programming enviroment. Expierment with this program: Code: #include <stdio.h>
#include <stdlib.h>
int main ( void )
{
FILE * Printer = fopen("LPT1", "w");
FILE * FilePointer;
char str[256];
char buf[BUFSIZ];
printf("File name?\n");
scanf("%s", str);
FilePointer = fopen(str, "r");
if( !FilePointer )
{
printf("File does not exist\n");
return -1;
}
while( fgets ( buf, sizeof buf, FilePointer ) != NULL )
{
fprintf(Printer, "%s", buf);
}
printf("\nPrinting..\n");
fprintf(Printer, "\f");
return 0;
}
__________________ The world is waiting. I must leave you now. |
| Shadow is offline | |
| | #5 |
| Casual Visitor Join Date: Oct 2001
Posts: 313
| For dos, try adding the linefeed and formfeed. I had a similar problem, but it was with masm not C. Adding the linefeed and formfeed solved the "not ready" problem. Code:
fputs("string\xA\xC", filep);
/* or your method of choice for file I/O */
__________________ I'm not a programmer.... I'm not a computer science major.... This is only a hobby.... Last edited by ronin; 08-03-2002 at 10:03 PM. |
| ronin is offline | |
| | #6 |
| Registered User Join Date: Aug 2002
Posts: 6
| After much experimenting to fix the very long Printer delay, I included: fprintf(prnt, "\f"); before the fclose(prnt); statement. The Printer output now occurs without delay..... All Smiles now!! /* "PRINTER OUTPUT TEST" */ #include <stdio.h> FILE *prnt; main() { prnt = fopen("lpt1", "w"); fprintf(prnt, "\nThis is TEST#1\n"); fprintf(prnt, "This is TEST#2\n"); fprintf(prnt, "This is TEST#3\n"); fprintf(prnt, "This is TEST#4\n"); fprintf(prnt, "\f"); /* Prevents Printer hangup */ fclose(prnt); return (0); } |
| noraa is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic C input output program help | trevordunstan | C Programming | 2 | 01-27-2008 06:41 PM |
| 2d game | JordanCason | Game Programming | 5 | 12-08-2007 10:08 PM |
| Having trouble making a function do what I want. | Shamino | C++ Programming | 9 | 12-07-2007 11:20 AM |
| Trying to store system(command) Output | punxworm | C++ Programming | 5 | 04-20-2005 06:46 PM |
| sorting output on student info program | indigo0086 | C++ Programming | 2 | 11-05-2002 11:29 AM |