My programe runs in the DOS console. I wish to send command to DotMatrix Printer to print Bold or extended type by using the outfile command. How can that be done ?
My programe runs in the DOS console. I wish to send command to DotMatrix Printer to print Bold or extended type by using the outfile command. How can that be done ?
Can you send any text to the printer at the moment?
Do you have the manual for the printer, or know what type (manufacturer / model) of printer you have?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yes sure I can send text to the printer (using the outfile command). But I wish to format it at some places, like making some text Bold and some Extended etc. Do we have any commands like we had in old BASIC to send instructions to the Printer. I do not want to stick to one brand of Printer would preffer to make it work universally on all Dot Matrix Printers.
Like for example, these codes
http://webpages.charter.net/dperr/links/esc_p83.htm
So italics would be "ESC 4"
In C, you would do this
Code:#define ESC "\033" outfile( ESC "4" ); outfile( "This is Italic text" ); outfile( ESC "5" );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thanx for the codes I would try them & return if needed. But do these esp codes work on all Dot Matrix Printers ?
What does the #define ESC "\033" Stands for ?
Last edited by 3DMatrix; 06-05-2004 at 11:43 AM.
> But do these esp codes work on all Dot Matrix Printers ?
Some of them are pretty standard - others are specific to a sub-set of printers
ESC is the escape character, which is 27 decimal, or 033 in octal
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
#include<iostream.h>
#include<fstream.h>
#define ESC "\033"
int main()
{
ofstream outfile;
outfile.open("PRN");
outfile( ESC "4" );
outfile( "SAMPLE TEXT" );
outfile( ESC "5" );
return 0;
}
The above code gives compilation Error. But the following does not. What changes should I do ? and which will work ?
#include<iostream.h>
#include<fstream.h>
#define ESC "\033"
int main()
{
ofstream outfile;
outfile.open("PRN");
outfile<<ESC "4";
outfile<<"SAMPLE TEXT"<<endl;
outfile<<ESC "5";
return 0;
}
> The above code gives compilation Error.
Because you've mixed the syntax of C and C++
> But the following does not. What changes should I do ? and which will work ?
What do you mean "doesn't work"
Doesn't compile
compiles, runs, but produces no output?
Do you have a new file called "PRN" by any chance?
One final thing, when sending stuff to the printer, you may have to do this command last
This sends a form feed to the printer, letting it know that output for the current page is complete, so it can now go and print it.Code:outfile << "\f";
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
OK let me try that !