View Poll Results: Who agrees with me that this thread should die?

Voters
5694. You may not vote on this poll
  • Should die now

    5,694 100.00%
  • Should let message board nature take it down the list

    0 0%

Clearing the console

This is a discussion on Clearing the console within the C++ Programming forums, part of the General Programming Boards category; If you want to use it then put it in preprocessor directives like this. Similar to that, but not exactly ...

  1. #46
    Nonconformist Narf's Avatar
    Join Date
    Aug 2005
    Posts
    174
    If you want to use it then put it in preprocessor directives like this.
    Similar to that, but not exactly like that. Otherwise you'd end up in preprocessor hell. How about defining a portable interface, then just changing the code behind the interface when you port the code:
    Code:
    void clear_screen() {
      system("CLS");
    }
    You call clear_screen() however many umpteen times you need to, but portability isn't affected because to go to Linux you only need to change one thing in one place, "CLS" to "clear" in the definition of clear_screen(). A lot of people seem to think portable code means you can compile everywhere without change. That's the ideal, sure. But almost any non-trivial program has to use non-portable stuff, so portability really means how easy it is to get code to compile somewhere else. A portable program fixes the deck so that there's only one point of change for any given non-portable feature.

    You can get the ideal by hacking each port into the program with the preprocessor, but that gets ugly and unwieldy very fast. I don't consider it ideal after two branches, even if you do it intelligently to avoid littering the code with preprocessor directives. If you can reach the ideal in a clean way, great! If not--like with clearing the screen--fix the deck for portability and go have a pint.
    Just because I don't care doesn't mean I don't understand.

  2. #47
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by Narf
    Similar to that, but not exactly like that. Otherwise you'd end up in preprocessor hell. How about defining a portable interface, then just changing the code behind the interface when you port the code:
    Code:
    void clear_screen() {
      system("CLS");
    }
    Yes I know all those preprocessor directives get pretty ugly very quickly. And it make it difficult to port the program to a new platform.

    This is exactly why programming discussion boards are so great today! You get a lot of different ideas from other programmers, making the end result a lot better for everybody. Using your idea we could put all os-dependent code in a library then link the program to whatever os lib we want.

  3. #48
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    Everybody seems to have their own method to clear the screen. They post their methods and get shot down. The people who shot down the other methods have their own methods shot down. Is there any function that everybody agrees is the best? I guess thats a dumb question but is there any way to do it that alot of people think is at least good? And can anybody that has curses.h in their library post it?
    Thanks,
    Last edited by beanroaster; 09-11-2005 at 09:24 PM.
    Adam

  4. #49
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,810
    There is no best way. You just have to do what works best for you.
    Woop?

  5. #50
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    Ok, but what is the most commonly used method?
    Adam

  6. #51
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by beanroaster
    Ok, but what is the most commonly used method?
    Out growing the need to clear the console at all.

  7. #52
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    If you're using a windows computer, I'd probably go with the WINDOWS CONSOLE OPTION listed in the FAQ.

    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    Or check Adrianxw's tutorial, there's probably one in there.

  8. #53
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    What is Adrianxw's tutorial? And how do I kill this thread?
    Adam

  9. #54
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    What is Adrianxw's tutorial?
    Look at his first post in the thread - it's like 5 down from the top.

    And how do I kill this thread?
    You don't. You get a mod to do it. And I agree - it should be dead. If anyone wants it reopened PM me or another mod.

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 10:59 PM
  2. Console Functions Help
    By Artist_of_dream in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 03:44 AM
  3. Clearing the screen in a dos console window...
    By Unregistered in forum C++ Programming
    Replies: 13
    Last Post: 02-15-2002, 04:15 AM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM
  5. clearing an NT console
    By iain in forum C++ Programming
    Replies: 1
    Last Post: 12-07-2001, 01:08 PM

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