Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing the screen in Windows XP?

Status
Not open for further replies.

kherge

Programmer
Nov 14, 2007
14
US
I have searched Google for about a day or two now and I did find a few examples. Unfortunately none of them worked.

What I would like to accomplish is the ability to clear the screen while in command (cmd). I have tried the following examples but none have worked:

[tt]system( "cls" );
passthru( "cls" );
exec( "cls" );
shell_exec( "cls" );
system( "command /C cls" );
echo chr( 033 ), "cm";
print( "\x1b\x5b\x58\x1b\x5b\x32\x4a" );
echo "\x1b\x5b\x58\x1b\x5b\x32\x4a";[/tt]

The result after trying the above is weird characters in the output. The screen will still not clear.

I have also used the "ghetto" way by adding new lines until the previous output was out of sight but the prompt will end up at the bottom of the screen instead of near the top.
 
you're using a CLI I guess!!

from the php manual I suggest trying this code

Code:
function clearscreen() {
 $clearscreen = chr(27)."[H".chr(27)."[2J";
 print $clearscreen;
}
 
I remember trying that before.

I tried it again anyway in case the previous example I used was wrong.

My result was (left arrow being the single character version of <- ):

Code:
(left arrow)[H(left arrow)[2J

I am not sure if it something in my code so I will provide a link to my repository:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top