generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: C++ clearing console window

Previous Thread :: Next Thread 
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 05:51 PM
If you have windows, check to see if this clears the console window:

write(1,"\E[H\E[2J",7);

just put that in your C++ application, it should do the trick.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:14 PM
Noob?
#include windows.h
...
system("clear");
...
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:14 PM
AGH
system("cls");
i hope im not late
Report Abuse
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 06:17 PM
thats not even cross platform, dude get into the game.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:18 PM
Because I imported WINDOWS.h, that's obvious.
Report Abuse
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 06:18 PM
why would I want to do that? when i could use something like that to clear the window and its much easier.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:19 PM
>write(1,"\E[H\E[2J",7);
>easier

>#include < windows.h>
>system("cls");

Yeah. Easier.
Report Abuse
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 06:20 PM
im not trying to argue over it, this makes it easier for me. i just wanted to know if it clears the console on windows.
Report Abuse
Smithy1241 is not online. Smithy1241
Joined: 07 May 2012
Total Posts: 80
08 May 2012 06:22 PM
@lord

Booing is actually write. Studies show that over 80% of computer users use Windows, and that another 80% of Mac users claim to also own or emulate a Windows PC. There is also software called Wine out that allows Mac users and Linux users to run Windows software.

Nothing is wrong with importing "windows.h". I, personally, use Visual C++ all the time.

If you're going to make a non-cross-platform application, Windows is the operating system of choice.

There are other ways to clear the Window. But "system("cls");" will work just fine.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:22 PM
It would have taken about 2x shorter to test it yourself.
Report Abuse
Smithy1241 is not online. Smithy1241
Joined: 07 May 2012
Total Posts: 80
08 May 2012 06:23 PM
If you want cross-platform, use Java.
Report Abuse
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 06:26 PM
one, there are going to be performance differences if I call system everytime i need it.
two, i want it cross-platform. besides, i dont like using wine as it is. what makes you think others will want to use it too?

boo,

id rather not re-install windows.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 May 2012 06:30 PM
Since you did not mention an os, I assumed windows because it is the most popular.
Report Abuse
lordmarine12 is not online. lordmarine12
Joined: 30 Apr 2012
Total Posts: 470
08 May 2012 06:31 PM
Oh, sorry about that. I just assumed you knew.
Report Abuse
pokelover980 is not online. pokelover980
Joined: 12 Jun 2009
Total Posts: 4141
08 May 2012 06:46 PM
Never use a system call, ever. Booing, while I would agree with you about catering to Windows because of its popularity, you should never, ever make a system call like that. It's incredibly inefficient, and is a bad habit to get into.
Report Abuse
L3GabeL4 is not online. L3GabeL4
Joined: 18 Feb 2012
Total Posts: 808
08 May 2012 06:48 PM
Thank you pokelover; someone finally could back me up.

Now, could you check to see if that escape sequence works on Windows?
Report Abuse
Smithy1241 is not online. Smithy1241
Joined: 07 May 2012
Total Posts: 80
08 May 2012 06:52 PM
@poke

There's never been a version of Windows that is not compatible with the "cls" command.

How is it not efficient?

ef·fi·cient/iˈfiSHənt/
Adjective:
(esp. of a system or machine) Achieving maximum productivity with minimum wasted effort or expense.

Using the "cls" command is actually much quicker and does the job better than a lot of self-written functions.
Report Abuse
L3GabeL4 is not online. L3GabeL4
Joined: 18 Feb 2012
Total Posts: 808
08 May 2012 06:59 PM
The 'cls' command is not cross platform, therefore it would not work on Linux or Mac.
On top of that calling system can be very 'resource heavy'. Besides, why are you even here? It's apparent you don't know much about C++ and the power of it if it's used correctly.
Report Abuse
LPGhatguy is online. LPGhatguy
Forum Moderator
Joined: 27 Jun 2008
Total Posts: 4725
08 May 2012 07:00 PM
@Smithy1241
It's also a bad security issue.
Imagine if you had a virus that changed one of the windows commands you use was replaced by a virus?

Also, it isn't efficient. Your application yields, control is given to the OS, the OS calls up whatever application you call, it executes, returns a code, control is given back to the OS, and then your application continues. This might not sound like much on a modern computer, but it's still an absolutely awful way to do things when there are much better ways.

Besides, I believe there's something in the std namespace from iostream if you must.
Report Abuse
L3GabeL4 is not online. L3GabeL4
Joined: 18 Feb 2012
Total Posts: 808
08 May 2012 07:02 PM
Someone check Windows and see if this would work to clear the console...


write(1,"\E[H\E[2J",7);

It works on Linux, and I need to make a cross platform application.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
08 May 2012 07:03 PM
>Using the "cls" command is actually much quicker and does the job better than a lot of self-written functions.

system("cls") invokes the shell environment, tells it to launch the command/executable "cls", launches "cls", waits for it to finish, and waits for the shell to return to the program.

While any other solution that doesn't involve "system()" is much faster.
Report Abuse
L3GabeL4 is not online. L3GabeL4
Joined: 18 Feb 2012
Total Posts: 808
08 May 2012 07:03 PM
^

Why did it take you so long to show up? I seen you on earlier and expected you to comment. =/
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
08 May 2012 07:05 PM
IDK I was doing some other stuff.
Report Abuse
L3GabeL4 is not online. L3GabeL4
Joined: 18 Feb 2012
Total Posts: 808
08 May 2012 07:06 PM
Well, could you find out if the escape sequence would work on the Mac? plllleaassse?
Report Abuse
Smithy1241 is not online. Smithy1241
Joined: 07 May 2012
Total Posts: 80
08 May 2012 07:08 PM
@mykros

Have you been using C++ for a day? I hope you know that it takes about a millisecond to do that.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image