Text Enhancement from DOS console

This is a discussion on Text Enhancement from DOS console within the C++ Programming forums, part of the General Programming Boards category; My programe runs in the DOS console. I wish to send command to DotMatrix Printer to print Bold or extended ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    5

    Text Enhancement from DOS console

    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 ?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    5

    Yes

    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.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    5

    Thanx

    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.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    May 2004
    Posts
    5
    #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;
    }

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    > 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
    Code:
    outfile << "\f";
    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.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    May 2004
    Posts
    5
    OK let me try that !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 02:17 PM
  2. Capturing dos text screen in C
    By hednast in forum C Programming
    Replies: 13
    Last Post: 08-11-2005, 07:49 PM
  3. How to print Right aligned Text in a console?
    By Aidman in forum C++ Programming
    Replies: 13
    Last Post: 03-09-2003, 09:43 PM
  4. ASCII Grafix Dos Console
    By Blizzarddog in forum Game Programming
    Replies: 19
    Last Post: 01-20-2003, 08:41 AM
  5. windows dos console
    By dune911 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2002, 10:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21