| Author |
Message |
ProgrammingFun

|
Posted: Tue Dec 28, 2010 9:18 am Post subject: Re: Clearing the Screen |
|
|
Unfortunately, this does not work for me either (I guess I'll just stick to no cls at all )
I tried the following:
| Java: |
import java.util.*;
public class Test
{
public static void main (String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println ("fsfdasfsa");
String fa = sc.next();
final static String CSI = "\0x1B[";
System.out.print(CSI + "2J");
System.out.flush();
String fsaf = sc.next();
System.out.println ("fsafa");
}
} |
I get the following error:
| Error: |
Test.java:11: modifier static not allowed here
final static String CSI = "\0x1B[";
^
1 error
|
If I try the following:
| Java: |
import java.util.*;
public class Test
{
final static String CSI = "\0x1B[";
public static void main (String[] args )
{
Scanner sc = new Scanner (System. in);
System. out. println ("fsfdasfsa");
String fa = sc. next();
System. out. print(CSI + "2J");
System. out. flush();
String fsaf = sc. next();
System. out. println ("fsafa");
}
} |
I get the following output:
| input_output: |
fsfdasfsa
my input <---this is what I inputted
00 x1B[2Jfsafa <---strangely, this line cannot be copied to the clipboard with Windows
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
btiffin

|
Posted: Tue Dec 28, 2010 9:55 pm Post subject: Re: Clearing the Screen |
|
|
Gee; is my lack of Java practice showing up.
I haven't Java'ed in over a decade now.
Perhaps the literal should be '\033[' for the octal equiv? instead of a 0x literal?
Dump the static modifier?
The objective is to create a string with ESCAPE (ascii 27) followed by "[2J". I'll have to leave those technicals to the people here that may actually know. And not us old farts that THINK they know
Cheers |
|
|
|
|
 |
ProgrammingFun

|
Posted: Tue Dec 28, 2010 10:00 pm Post subject: RE:Clearing the Screen |
|
|
Nope...same problem....
Thanks for the help tho!  |
|
|
|
|
 |
ProgrammingFun

|
Posted: Thu Dec 30, 2010 9:19 am Post subject: RE:Clearing the Screen |
|
|
One more question regarding console....is there any way (non GUI) to give a new popup window in the current console if the user chooses a certain option?
I want the instructions/game rules to popup in a seperate window when the user forgets the rules... |
|
|
|
|
 |
Tony

|
Posted: Thu Dec 30, 2010 1:38 pm Post subject: RE:Clearing the Screen |
|
|
I thought new windows/tabs spawned new (independent) shells...
Really, it sounds like you are trying to bring too much of GUI mentality over to the console. They are supposed to be different. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
ProgrammingFun

|
Posted: Thu Dec 30, 2010 2:10 pm Post subject: RE:Clearing the Screen |
|
|
| So there is no possible way to do this in console? |
|
|
|
|
 |
Tony

|
Posted: Thu Dec 30, 2010 3:05 pm Post subject: RE:Clearing the Screen |
|
|
| You could maybe spawn a new shell and have it run a separate program... I'm murky on the details. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
SS1389
|
Posted: Thu Dec 30, 2010 7:56 pm Post subject: Re: Clearing the Screen |
|
|
No need for it ProgrammingFun, it won't make the program any better  |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
ProgrammingFun

|
Posted: Thu Dec 30, 2010 9:02 pm Post subject: Re: Clearing the Screen |
|
|
SS1389 @ Thu Dec 30, 2010 7:56 pm wrote: No need for it ProgrammingFun, it won't make the program any better 
I came up with another way to do it...and yes, it will make it better in one way.... |
|
|
|
|
 |
copthesaint

|
Posted: Fri Dec 31, 2010 11:46 am Post subject: RE:Clearing the Screen |
|
|
The main point of the console screen is for general debugging for your program eg: mathematical problems. Its something that would only be shown in the console and not on the application that is running. o to clear this would be unwise.
For example what if you run this program and it does clear all the text every time, however it also clears warnings and exceptions when the program comes to a runtime error. For example you use the scanner class improperly. I personally think clearing it would be a bad choice. since it is intended for more important uses.
That being said you probably still want to find a way to clear the screen lol.
So I have to ask also, this much effort trying to clear the screen, why not just make a normal application? and you can clear any text all you want  |
|
|
|
|
 |
ProgrammingFun

|
Posted: Fri Dec 31, 2010 1:45 pm Post subject: Re: RE:Clearing the Screen |
|
|
copthesaint @ Fri Dec 31, 2010 11:46 am wrote: That being said you probably still want to find a way to clear the screen lol.
So I have to ask also, this much effort trying to clear the screen, why not just make a normal application? and you can clear any text all you want 
Nah, I'm past the screen-clearing dilemma....solution: Don't clear the screen
I cannot make a normal application because I have not been taught GUI as of yet and the compiler my school uses is not very GUI-friendly...it would be much much easier if I knew GUI |
|
|
|
|
 |
Tony

|
Posted: Fri Dec 31, 2010 2:21 pm Post subject: RE:Clearing the Screen |
|
|
This will be of interest to this thread
http://twitter.com/#!/camilleroux/status/20913572372549632
| code: |
ruby -e 'def a;10.times{puts " "*rand(79)+"*"};end;99.times{a;puts " "*34+"Happy New Year 2011";a;sleep 0.1;puts "\e[2J"}'
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
TerranceN
|
Posted: Fri Dec 31, 2010 2:42 pm Post subject: RE:Clearing the Screen |
|
|
"the compiler my school uses is not very GUI-friendly"
And what compiler would that be? I know of only sun's JDK and the one in gcc, and I thought they worked the same. |
|
|
|
|
 |
ProgrammingFun

|
Posted: Fri Dec 31, 2010 2:55 pm Post subject: Re: RE:Clearing the Screen |
|
|
TerranceN @ Fri Dec 31, 2010 2:42 pm wrote: "the compiler my school uses is not very GUI-friendly"
And what compiler would that be? I know of only sun's JDK and the one in gcc, and I thought they worked the same.
My school uses jGRASP, which according to my teacher, is not the best thing to use with GUI...but I myself have run GUI programs using it.... |
|
|
|
|
 |
SS1389
|
Posted: Fri Dec 31, 2010 3:07 pm Post subject: Re: Clearing the Screen |
|
|
| I'm sure you have. |
|
|
|
|
 |
|