473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ANSI clear screen [MS & Borland]

Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie
Nov 13 '05 #1
20 8111
Search for "Microsoft Knowledge Base Article - 99261"

That should work on both compilers given that you're making a win32 console
application.

--

Elias

"ritchie" <ri*********@yahoo.com> wrote in message
news:3b**************************@posting.google.c om...
Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie

Nov 13 '05 #2
ritchie wrote:

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers,
especially Borland & MS Visual Studio 6.


Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.

After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 13 '05 #3
CBFalconer wrote:
Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.
And that (as you know) isn't a portable technique either.

After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #4
Greetings.

In article <3b**************************@posting.google.com >, ritchie
wrote:
Is there anything that will clear the screen in both and maybe also
work on gcc?


Maybe putchar('\f')... if that doesn't work, use the compiler-provided
implementations and wrap them around #defines. (Presumably each
compiler will #define some macro identifying it. I know GCC does. If
Borland and Microsoft don't, you're probably out of luck.)

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #5
Richard Heathfield <do******@address.co.uk.invalid> wrote:
CBFalconer wrote:


[How to clear screen]
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)


No need to put it back. I use a damp cloth and a tiny little bit of
detergent to clear the screen, and the data doesn't get rubbed off -
it stays nice and clear where it was. :)
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc : http://www.angelfire.com/ms3/bchambl...me_to_clc.html
clc faq-list : http://www.eskimo.com/~scs/C-faq/top.html
acllc-c++ faq : http://www.contrib.andrew.cmu.edu/~a...acllc-c++.html
Nov 13 '05 #6
On Sat, 06 Dec 2003 21:19:40 +0100, in comp.lang.c , Irrwahn
Grausewitz <ir*******@freenet.de> wrote:
Richard Heathfield <do******@address.co.uk.invalid> wrote:
CBFalconer wrote:


[How to clear screen]
> After all that, don't do it. There is nothing more annoying than
> gratuitious screen clearings from imbecelic programs removing data
> I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)


No need to put it back. I use a damp cloth and a tiny little bit of
detergent to clear the screen, and the data doesn't get rubbed off -
it stays nice and clear where it was. :)


I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #7
Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.

Nov 13 '05 #8
On Sat, 06 Dec 2003 16:56:38 -0600, in comp.lang.c , Morris Dovey
<mr*****@iedu.com> wrote:
Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


See, these problems wouldn't arise if people didn't give offtopic
answers here. Any fule kno that your kind of router is pronounced to
rhyme with shouter, and the sort you /should/ have wiped with solvent
is pronounced to assonate with tooter. If only you yanks could learn
to spel too, we'd be laffin.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #9
Richard Heathfield wrote:
CBFalconer wrote:
Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:
^^^^^^^

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.
And that (as you know) isn't a portable technique either.


Note underlined word above :-)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the
current terminal window), as long as he puts the old data back
afterwards. :-)


Disagree. Consider a calculator program. While using it I want
the data that was previously left on my screen.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 13 '05 #10
>I am trying to clear the screen in my program.
1. What screen? Who says there is one?
2. Which screen? Who says there is only one?

ANSI C does not require a screen. Having stdin and stdout connected
to an ASR-33 teletype meets the requirements (what few there are
in this respect) of ANSI C. There is *NO* ANSI C solution to your
problem.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.


How does one even try clear the screen on a terminal that prints
on paper? Is this the screen that prevents dirt from clogging up
the bathtub drain?

Gordon L. Burditt
Nov 13 '05 #11
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


On Sat, 06 Dec 2003 09:22:04 -0800, ritchie wrote:
Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie


Nov 13 '05 #12
Morris Dovey wrote:

Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(
Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


I just hope nobody here has an automated sawmill.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.

--
Les Cargill
Nov 13 '05 #13
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


Please don't top-post, and please don't post non-portable answers. This
groups is for the C language, not for tricks that won't even work on
most platforms. This is in the FAQ:

http://www.eskimo.com/~scs/C-faq/q19.4.html

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Nov 13 '05 #14
CBFalconer wrote:
Richard Heathfield wrote:
CBFalconer wrote:
> Since you carefully read the FAQ, you are now aware that this
> cannot be done in standard C. About the closest you can come is:
^^^^^^^
>
> puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");
>
> and you may need to adjust the \n count.


And that (as you know) isn't a portable technique either.


Note underlined word above :-)
> After all that, don't do it. There is nothing more annoying than
> gratuitious screen clearings from imbecelic programs removing data
> I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the
current terminal window), as long as he puts the old data back
afterwards. :-)


Disagree. Consider a calculator program. While using it I want
the data that was previously left on my screen.


Clearly, you would not use a calculator that clears your screen, then.
(Neither do I. I keep forgetting that bc doesn't clear the screen, and I'm
always relieved to see that it doesn't, for precisely the reason you gave.)

On the other hand, does your usual source code text editor take full control
over the window in which its output appears? Mine does. And yet I use it
cheerfully.

In other words, it all depends.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #15
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


I tried this on one of my machines at home, and it just printed a little
backward-arrow thing, followed by [J

It certainly didn't clear the screen.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #16
"Richard Heathfield" <do******@address.co.uk.invalid> wrote:
On the other hand, does your usual source code text editor take full
control over the window in which its output appears? Mine does. And
yet I use it cheerfully.


When I invoke my usual source code text editor with a command like:
C:\docs\prog\c>text rheathfield.c
It pops up its own window leaving my shell window intact. That's the
way I like it.

Even when I am forced to use terminal-based screen editors I usually
still open up another terminal window for the editor so that I can
switch from shell prompt to editor quickly without having to close
the editor.

--
Simon.
Nov 13 '05 #17
In article <3F***************@worldnet.att.net>, lc******@worldnet.att.net
says...
Morris Dovey wrote:

Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


I just hope nobody here has an automated sawmill.


Well, that computer controlled minigun from an Aegis missile cruiser
we're working on in the lab may not take kindly at all to a clear screen
command.

--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: po********@sco.com
Nov 13 '05 #18
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


My Volker Craig VC4404 just went into INSERT mode, and displayed a bunch of
funny characters. OTOH, my ASR33 teletype just printed [J

Oh, and it didn't do anything for my 3277 display.
--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.

Nov 14 '05 #19
In <3f***********************@news.free.fr> Bruno Desthuilliers <bd***********@removeme.free.fr> writes:
CBFalconer wrote:
(snip)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic


Is that a true, out-of-the-dictionnary english word ? (sorry, I don't
have my english dictionnary with me - she went to bed early tonight !-)


What is a "dictionnary"? ;-) And English is *always* spelled with a
capital E.

Before pointing out other people's typos/misspellings, check yours!

The proper spellings are "imbecilic" and "dictionary".

Dan

P.S. http://www.m-w.com seldom goes to bed ;-)

--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #20
Bruno Desthuilliers wrote:
CBFalconer wrote:
(snip)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic


Is that a true, out-of-the-dictionnary english word ? (sorry, I don't
have my english dictionnary with me - she went to bed early tonight !-)


Typo. Try imbecilic.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
8
by: Kris Dugan | last post by:
I am using a Unix/Solaris 8/9 environment. I want to make a tool that will constantly read a structure of information and display that information (or "paint it") to the screen. Rather than...
2
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program...
3
by: thelaery | last post by:
Hi, I'm trying to read the belgium eid card which gives out utf8, i can convert it to ansi but now i have the problem of converting the special chart to oem. utf8 to ansi...
0
by: MaartenVR | last post by:
sub: MS SQL server and (missing) ANSI DATE-datatype I’m working at a company who has developed a large client/server application in Delphi 6, with Interbase as the DB-server (both Borland...
65
by: Leslie Kis-Adam | last post by:
Hi everyone! Does anyone know, if it is possible to clear the screen in ANSI C? If it is,then how? Any help would be appreciated. Laszlo Kis-Adam <dfighter_AT-NOSPAM_freemail.hu
1
by: wschlanger | last post by:
Hi, the following code behaves differently for GCC/MSC and Borland C++ 5.6. The question was, what order does symbol lookup happen in? 1. declared symbols, including using'd symbols. 2....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.