Computer Science Canada Clearing the console screen? |
Author: | Jonny Tight Lips [ Thu Sep 29, 2005 8:26 am ] |
Post subject: | Clearing the console screen? |
Just wondering if it is pssoble to clear the console screen kind like cls in turing. Any help would be great. Thx |
Author: | wtd [ Thu Sep 29, 2005 11:28 am ] |
Post subject: | |
No, it's not. Turing doesn't have a console screen. You don't want to clear the screen anyway. The user knows what he or she typed. Wiping it out only serves to make the program more difficult to use. If you want something like a piece of text centered on the screen, with whitespace all around, in Java you can either use Swing or SWT. |
Author: | 1of42 [ Fri Sep 30, 2005 6:18 pm ] | ||
Post subject: | |||
wtd is incorrect - on Windows:
will clear the console screen. using system calls is bad practice, and will make your program non-portable, but it IS possible to do. |
Author: | wtd [ Fri Sep 30, 2005 6:30 pm ] | ||
Post subject: | |||
The language in question is Java. The quickets way to do this in Java would be:
|
Author: | [Gandalf] [ Fri Sep 30, 2005 7:30 pm ] |
Post subject: | |
Would that be portable, or not? |
Author: | wtd [ Fri Sep 30, 2005 7:39 pm ] |
Post subject: | |
[Gandalf] wrote: Would that be portable, or not?
It would not. It would require that the underlying system understand "cls". |
Author: | 1of42 [ Fri Sep 30, 2005 9:40 pm ] |
Post subject: | |
Well, so wtd, I'm still right - it's not my fault that I thought this was C++ (i'm tired)! I swear! |
Author: | wtd [ Fri Sep 30, 2005 9:44 pm ] |
Post subject: | |
Yes, unfortunately you're right. |
Author: | Hikaru79 [ Fri Sep 30, 2005 11:40 pm ] | ||
Post subject: | |||
Of course, if you're REALLY desperate to do this, and want it to be relatively portable, there's always something like this:
This is far from perfect, but it might be enough for some purposes. |
Author: | wtd [ Fri Sep 30, 2005 11:43 pm ] | ||||
Post subject: | |||||
Should possibly be:
|