Need some quick Java help

purpledemon

Senior member
Jun 21, 2001
291
0
0
error : your if statement is not enclosed in paren. Everything from the "if" to the "{" needs to be enclosed.

possible error : where are currentRoom and asec declared? I dont see them in your code block.

warning : you should use equals instead of == for that string compare
 

BigCoolJesus

Banned
Jun 22, 2005
1,687
0
0
Is there a way to write a expression or prompt that will clear the SOP screen (system.out.println) while the program is running?


like if an integer value = a certain value, is there a statement i can write that clears the SOP?
 

lordex

Member
Feb 7, 2002
133
0
0
The only way I can think of is Runtime.exec("<cmd>"), where <cmd> depends on your native OS, e.g., "cls" in windows.
 

purpledemon

Senior member
Jun 21, 2001
291
0
0
you could scroll a number of lines to emulate the effect.
or
start working wth swing if it doesnt have to be a console app
 

Jeff Peake

Member
Nov 25, 1999
71
0
0
Yes there is a way to do this, I have done it in a java app long ago. I dont remember hte code, but I think it was system.out.reset or something like that. I used it to keep a progress-meter drawing on the same line of the console.

JP

 
Sep 29, 2004
18,656
67
91
Originally posted by: BigCoolJesus
Is there a way to write a expression or prompt that will clear the SOP screen (system.out.println) while the program is running?


like if an integer value = a certain value, is there a statement i can write that clears the SOP?

You want to clear the console window and place the "cursor" at the top of the console, correct?

And no, I don't knwo how to do it. Should be tricvial though, go look through the JDK's System.out methods.
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
System.out is just a PrintStream - I don't think it has the functionality to clear using a method. Googling, there appears to be three strategies (some mentioned in this thread):

1) Use the runtime to call CLS
2) Print enough empy lines to remove the previous output and end up with a blank screen
3) System Specific: For Win9x, not sure if it'll work on 2k/XP

You might want to reconsider trying to implement this. None of the options appear terribly 'clean'. Why do you need it?