CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    Jun 1999
    Posts
    19

    ANSI escape sequences in console apps don't work, help!

    Why do the ANSI escape sequences not work with MS Visual C++?

    #include <stdio.h>
    void main(void) {
    printf("%c[2J", 27); //clear the screen
    }

    This works fine when I compile it with the old MS C 6.0
    This does not work with MS Visual C++ 4.0 and MS Visual C++ 5.0.
    Why? Please help!

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: ANSI escape sequences in console apps don't work, help!

    ansi.sys needs to be in your C:\config.sys file


    You need to have the%2

  3. #3
    Join Date
    Jun 1999
    Posts
    19

    Re: ANSI escape sequences in console apps don't work, help!

    Please, no more "Do you have your ANSI.SYS loaded?" replies.
    This is NOT the problem, as I said if you read the message. I works with MSC 6.0
    but not Visual C++. Obviously ANSI driver support is loaded.
    Again, why does Visual C++ send characters directly to the console and not through the ANSI
    driver?
    Please, someone who know the answer reply.
    Thanks!


    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ANSI escape sequences in console apps don't work, help!

    Did ANSI.SYS hook interrupt 10H? If it did, and VC++ does not print through int 10H, this may be the answer. You can trace through the source code to see eventually where the characters are going.

    Regards,

    Paul McKenzie


  5. #5
    Join Date
    May 1999
    Posts
    17

    Re: ANSI escape sequences in console apps don't work, help!

    I absolutely can't believe the moronicness of your reply. I hate to be
    an nasty but...
    I just aggravates me to no end when someone who has no concept of the
    problem offers
    and idiotic suggestion such as your. You make others thing, oh, problem
    solved, I guess
    I won't give this any more thought, you make yourself look stupid and
    you don't help me.

    1) If you read the message you would see that the MSC 6.0 version works,
    duh!
    I guess ANSI.SYS is loaded.
    2) There is no config.sys in Windows NT.

    Thanks for the info. I have never used NT, but I have used a quite a bit of dos and window 95. - (If its any consolation)

    I am not trying to start a war, that is why I am sending you this in a
    private message.

    It might as well be public. It will be more benficial being public.

    Just keep your mouth shut if you don't know the answer.
    I'll bet you
    were one of those kids
    in school that yell out the wrong answer without raising his hand.

    Sorry, can't say that I ever was one of those people.

    P.S. Sorry for being so nasty but you really pissed me off.

    If you were really sorry...why bother to write a rude letter? Your not sorry. I am sure you enjoyed it. Its human nature.

    I just thought I would offer some assistance. If you helps you great. If it doesn't don't worry about it. I have a real hard time believing you have never made a mistake or accidently given someone the wrong advice. Its sometimes hard to see yourself out of the same lense you look at other people with.

    By your responce, I would say that you are in a extreem frustration, and you have a great, great deal of pride and arrogance. (Why would a fool such as myself attempt to answer the question of a great master? =( ) Maybe you should deal with the pride and arrogance first, before trying to find a programming solution.

    You are partialy right, however. I just quickly scanned your post hoping you made a simple mistake that I could help you out with. I am only 20 and still learning and growing. Perhaps I can help you with something in the future...or maybe you could help me out instead. I will learn from this. Thanks for the lesson.

    I hope you find and answers to your questions.
    - Chris
    --
    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

    Ed Johnson - mailto:[email protected]


  6. #6
    Join Date
    Jun 1999
    Posts
    19

    Idiot

    I think you have proven my point.

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  7. #7
    Join Date
    Jun 1999
    Posts
    19

    Re: ANSI escape sequences in console apps don't work, help!

    That's a very interesting theory. I would think that printf() and ANSI.SYS should be written to work
    together. Anything less I would consider a bug in the C++ compiler or the ANSI driver. If you are
    correct, how can we get a fix? Why would MS drop support for ANSY.SYS? Would'nt that be a
    requirement, (to be ANSI compatable)?

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  8. #8
    Join Date
    Jun 1999
    Posts
    19

    Re: ANSI escape sequences in console apps don't work, help!

    "Did ANSI hook int 10h?" You mean you don't know? Please no more guesses.
    I need a factual answer from some one who KNOWS the answer. While this question
    may seem simple on the surface. Its not a question the unknowledgeable should attempt with
    quippy answers.
    Thanks anyway.

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  9. #9
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ANSI escape sequences in console apps don't work, help!

    The only way that a system driver like ANSI.SYS could work would be to hook the interrupts that write to the screen. Unless you know of any other method, this is the only method that I'm aware of.

    The simplest thing is to look at the RTL source for printf(). Somewhere, it will call one of the basic console I/O functions. Within that function is where the difference lies between what is occurring between the versions of VC++.

    As to the nature of your responses:
    CodeGuru is not Microsoft's Technical Support Line. Your response to me seems a bit out of whack. If you really wanted to know the answer to this, you could have done what I suggested and see if it is the case. If it's not the case, you can let me know in a less abusive manner.

    Unknowledgable? I've been doing this a long time now (20 years and an adjunct CS professor at a major university), maybe you have too. The difference between you and I is that I will attempt to take every suggestion and investigate and explore if I do not know the answer myself, and not wait for the "magic bullet" answer on an Internet discussion board.

    Regards,

    Paul McKenzie



  10. #10
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: ANSI escape sequences in console apps don't work, help!

    Well.... I just tested the following code under VC++ 5.0

    #include <stdio.h>

    int main(int argc, char* argv[])
    {
    printf("Test");

    printf("%c[2J", 27); //clear the screen

    printf("Test\n");

    getchar();

    return 0;
    }

    and it works perfectly when ANSI.SYS is loaded (the same code works under VC++ 6 as well on a separate system)... so that would all lead us to wonder what's wrong with your system? The obvious first thought would be that you're an idiot and you didn't have ANSI.SYS loaded... if that's not the case, then I don't know... I'd definately look into some of the console functions such as SetConsolMode.

    Which OS are your running (just curious)?

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

  11. #11
    Join Date
    May 1999
    Location
    WA
    Posts
    236

    Re: ANSI escape sequences in console apps don't work, help!

    // clrscrn.cpp
    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    printf("Test screen clear -> ");
    system("CLS");
    printf(" Test\n");
    printf("Please press 'Enter' key: ");
    getchar();
    return 0;
    }

    This isn't what you asked for, but it works.

    Roger L. McElfresh

  12. #12
    Join Date
    Jun 1999
    Posts
    19

    Re: ANSI escape sequences in console apps don't work, help!

    I guess I should have said it before, my mistake.

    I am running: Windows NT Version 4.0 Build 1381 Service Pack 4.0

    To all you Windows 95/98 users...
    FYI: Windows NT does NOT use a config.sys.
    Even if it did, How would you explain the MCS 6.0 version working with out ANSI.SYS loaded?

    You solutions so far...
    "ANSI.SYS needs to be loaded" - (Obviously it it loaded if MSC 6.0 version works.)
    "ANSI.SYS needs to be in your c:\config.sys" - (What if I my config.sys is on d:?)
    "It works on my machine" - (Thank you, I guess that fixes it.)
    "Look through the source" - (I did, dead end, the low level code is not there)

    Please forgive my abrasivness, but no answer given has solved the problem so far...

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  13. #13
    Join Date
    Jun 1999
    Posts
    19

    Re: ANSI escape sequences in console apps don't work, help!

    This batch file does'nt work either...

    @echo off
    echo {esc}]2J

    Which leads me to ask, how does one check for the ANSI driver being loaded in NT?
    And how do you load it since it does NOT use a config.sys file?

    Have you been to my home page lately?
    Home page: http://www.geocities.com/SiliconVall...5230/index.htm

  14. #14
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: ANSI.SYS and NT

    Well it wasn't hard to find on the web...

    http://www.nthelp.com/40/ansiNT.htm

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

  15. #15
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: ANSI escape sequences in console apps don't work, help!

    You also may want to check out Q100394 and Q101875, the latter being on the net at http://ftp://ftp.microsoft.com/bussy.../q101/8/75.txt.

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured