|
-
Mar 5th, 2002, 12:05 AM
#1
Thread Starter
New Member
How to clear DOS screen?
In C, by calling clrscr() from <conio.h>, we can clear a DOS screen. So how could I achieve the same action in Java?
-
Mar 5th, 2002, 03:06 AM
#2
Addicted Member
you can't. As far as i know (and do tell me if i'm wrong) there is no way of clearing the console, just as there is no way of writing to a specific co-ordinate on the console.
If you want to do anything like that your gonna have to look at painting with guis and stuff!
Ford? Theres an infinite number of monkeys outside that want to talk to you about a script of hamlet they've produced!
-
Mar 6th, 2002, 04:09 AM
#3
Thread Starter
New Member
got it ... but don't know how?
****************************************************
char esc = 27;
String clear = esc + "[2J";
System.out.print(clear);
And this line must be inside the config.sys:
device=c:\windows\command\ansi.sys
****************************************************
Finally, I found a code that can really clear off the console DOS screen in Window. However, I have big trouble in understanding the mechanism behind the code. Here is all the questions:
1) Why do I need this token "[2J"? What is it used for?
2) Why must I load the driver "ANSI.SYS" in order to have the program to work properly?
3) What is the mechanism that drives the program to clear off the DOS screen?
-
Mar 7th, 2002, 12:03 AM
#4
Hyperactive Member
looks like it relies on some native stuff by the fact it requires to you to use you config.sys. it maybe a code that is understood by your video driver as "clear screen" but that wouldn't be very portable and hence not very javaesque
good to be back in the forum!
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
-
Mar 8th, 2002, 05:51 PM
#5
Lively Member
Fill the ms-dos video buffer with null values. Normally everything shown in an ms-dos screen is stored in memory location B800H:0000H . The computer simply reads that area of memory over and over again really quicly to see what to put on the screen. If you go into ms-dos you can use microsfts debug.exe to have a look a round memory and see what's going on in the video buffer. Type the following at the command prompt (ignore the '>' signs)
>debug
Debug should load up if it's uncluded with your os. Now type:
>d B800:0000
Now you should see the contents of the screen displayed at the right hand side.
you can change those contents by typing:
>e B800:0000
Put in your own vaules and see what happens to the ms-dos screen. All you need to do now is work out how to do that in java ad you'll be able to do a lot of weird and wonderful things with the ms-dos screen. This probably isn't the best way top go about doung this but it'll give you an understanding about how things are displayed in ms-dos.
PS. It would probably help if you know some hex as each of the characters shown in an ms-dos prompt are stored as hexadecimal values and so are the atrributes (Background/foreground colour) for each character but even without knowing hex you can still do most of it. To make a blank screen just fill the video memory with zeros. If anyone gets this to work in java please email me a sample code, thanks. My email is [email protected]
-
Mar 10th, 2002, 10:54 AM
#6
You can use that :
Code:
public void cls()
{
for (int i = 0; i < 26 ; i ++)
System.out.println();
}
-
Mar 12th, 2002, 03:02 PM
#7
Hyperactive Member
DOAK: can you change the colour of the text that appears in the console?
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
-
Mar 15th, 2002, 06:23 PM
#8
No sorry for that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|