
-----------------------------------
Jonny Tight Lips
Thu Sep 29, 2005 8:26 am

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

-----------------------------------
wtd
Thu Sep 29, 2005 11:28 am


-----------------------------------
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.

-----------------------------------
1of42
Fri Sep 30, 2005 6:18 pm


-----------------------------------
wtd is incorrect - on Windows:


system ("cls");


will clear the console screen.

using system calls is bad practice, and will make your program non-portable, but it IS possible to do.

-----------------------------------
wtd
Fri Sep 30, 2005 6:30 pm


-----------------------------------
The language in question is Java.  The quickets way to do this in Java would be:

Runtime.getRuntime().exec("cls");

-----------------------------------
[Gandalf]
Fri Sep 30, 2005 7:30 pm


-----------------------------------
Would that be portable, or not?

-----------------------------------
wtd
Fri Sep 30, 2005 7:39 pm


-----------------------------------
"]Would that be portable, or not?

It would not.

It would require that the underlying system understand "cls".

-----------------------------------
1of42
Fri Sep 30, 2005 9:40 pm


-----------------------------------
Well, so wtd, I'm still right - it's not my fault that I thought this was C++ (i'm tired)! I swear! :lol:

-----------------------------------
wtd
Fri Sep 30, 2005 9:44 pm


-----------------------------------
Yes, unfortunately you're right.

-----------------------------------
Hikaru79
Fri Sep 30, 2005 11:40 pm


-----------------------------------
Of course, if you're REALLY desperate to do this, and want it to be relatively portable, there's always something like this:import java.io.*;

public class Test{
	
	public static void main (String 
This is far from perfect, but it might be enough for some purposes.

-----------------------------------
wtd
Fri Sep 30, 2005 11:43 pm


-----------------------------------
/usr/bin/clear

Should possibly be:

/usr/bin/env clear
