473,516 Members | 3,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want to clear a portion of screen - How??

I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.

Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.

I want a "simple solution".

I tried the combination of "\r\b" escape sequences. But \b is not
taking me back to the above line?
I urgently need the key for this.
Please help me achieving this.

I daily visit my topic to see whether I got the answer or not!
Thank you.

Sep 2 '06 #1
11 5325
Rajendran said:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.

Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.
Standard C has no solution to your problem. (Standard C does not offer
full-screen addressing.)

I suggest you ask your question in comp.unix.programmer where (I trust) the
experts there will be able to offer you a platform-specific solution.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 2 '06 #2
Rajendran wrote:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.
See question 19.4 in the FAQ: http://www.c-faq.com
Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.
comp.unix.programmer is your friend.
I want a "simple solution".
The (n)curses library is pretty simple. There's probably not much to gain
from even simpler solutions, since they won't transfer to other platforms,
and learning them is a waste of time.
I tried the combination of "\r\b" escape sequences. But \b is not
taking me back to the above line?
\b is backspace, which "moves the active position to the previous position
on the current line. If the active position is at the initial position of a
line, the behavior of the display device is unspecified." In other words,
you can't use backspace that way and expect it to work.

S.
Sep 2 '06 #3
Rajendran said the following, on 09/02/06 03:00:
I just want to clear the above three lines from the current position,
so that I can start printing my results from that point. In short I
want to clear a portion of my screen.
The C language has no standard facilities dealing with the "screen", and
not all implementations have anything that could be so described.
Please have a look at the FAQ, <http://www.c-faq.com/>, especially
Section 19, "System Dependencies".
Note: I work in the UNIX environment using gcc compiler. And I'm not a
super user.

I want a "simple solution".
A better place to post this question would be comp.unix.programmer.

[OT]
In a Unix/Linux environment, your best bet is probably to use
screen-handling tools contained in the 'ncurses(3)' package. They are
pretty simple to use, and will allow your program to work with a wide
range of display devices.
[/OT]

--
Rich Gibbs
ri*****@gmail.com
"You can observe a lot by watching." -- Yogi Berra

Sep 2 '06 #4
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!

Sep 3 '06 #5
Peyman said:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file,
That advice is not going to do him any good. The probability of there being
a <conio.hheader on his Unix system is vanishingly small, and the
probability that it is useful to him is even smaller.

<snip>
but still, comp.unix.programmer is your friend!
That advice, however, works fine.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 3 '06 #6
Thanks to all of you!
I already posted this question as you said - on unix.progammer

Finally I started learning ncurses but the example programmes are
giving strange results on my screen. Anyhow ncurses is interesting.

Anyway I "still welcome" your solutions

Sep 3 '06 #7
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!
Sep 3 '06 #8

"Rajen" <ra*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
>I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!
The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").

------------- W H G

Sep 3 '06 #9
Thanks WHG,
What does RTFM Mean? I came to know the esacpe sequences and I'm
comfortable with them.
esc[4A - Takes the cursor four lines up from current postion
esc[#B - " # lines down "
esc[#C - # columns forward
esc[#D #columns backward
-----------------------------------------------------------------
W H G wrote:
The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").

------------- W H G
Sep 4 '06 #10
Op 4 Sep 2006 05:07:10 -0700 schreef Rajen:
Thanks WHG,
What does RTFM Mean? I came to know the esacpe sequences and I'm
http://www.acronymfinder.com/
--
Coos
Sep 4 '06 #11

W H G wrote:
"Rajen" <ra*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hello Peyman,
could you please give me any websites relating to this.
what does /j do? I started searching the net. Reply me.
Thank you.
-Rajen
Peyman wrote:
I'm not quite sure about this, but google for an implementation of
"conio.h" header file, and find the implementation for function
clearScreen() or something like that, it should look something like:
printf("03[4[/j/r"); // roughly to give an idea about how strange it
is!
you might do the thing by a bit of hacking into this code.
but still, comp.unix.programmer is your friend!

The answer to clearing the screen is to use whatever function
your compiler vendor supplied. If the compiler was meant for
regular computer use it probably has a function - but it is off topic
for this group. RTFM

Ignoring that advice, make sure you have and ANSI screen driver
installed, and look up the codes for it. I went back to MSDOS 4
document. The driver is ANSI.SYS. All the codes start with
an escape character, aka, octal 033, decimal 27 or hex 1B.
Clear the screen is escape [2J so printing that should clear the screen.
puts("033[2J");
I suspect the previous poster worked from memory ( "something like").
Yes, exactly, thank you for correcting me, what I meant was:
printf("033[2J");
or as you said, it can be:
puts("033[2J");
>
------------- W H G
Sep 4 '06 #12

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

Similar topics

19
105747
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: System.out.print((char)27 + "[2J");
6
22239
by: jcollins | last post by:
Is there a command in Python to clear the screen? That is without writing multiple blank lines. Thanks. Jim C
18
59609
by: Tim Mierzejewski | last post by:
How do I clear the text from my screen, other than a bunch of \n's or endl's? Tim M.
6
2648
by: KL | last post by:
I was thinking...not always a good thing...is there a way to clear your screen. Like my current program asks a question and then posts 6 possible answers to choose from. Once a valid answer is chosen, it goes on to the next question, but it is hard to follow, so I was wondering if I could clear the screen after the answer was given and...
20
8123
by: ritchie | last post by:
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.
0
857
by: johni58 | last post by:
I have several VB6 applications that I am rewriting in VB2005 Express. I used invisible control arrays to place labels over snapshots on a thumbnail screen. Choosing one of the thumbs would open the enlarged version of that thumb from a file folder of jpgs. Unfortunately VB2005 no longer has a way to make a click event on a particular portion of a...
8
64475
by: REDBAIT | last post by:
Hi Guys, Am using Windows 2000 and Dev C++ to create C programs. I'm trying to use clear screen and other graphic functions such as positioning output on screen. Have seen some documents that suggest i use curses.h or system("clear") for clear screen, for example but all this has failed.
0
1596
by: sajithamol | last post by:
I have an Applet that has three buttons on it, one being a clear screen button. I have it setup right now so it draws a rectangle the size of the applet and fills it with the background color. But when it does that my other two buttons disappear until I mouse over them again. Is there a better way to clear screen or anyway for the buttons to show...
2
3785
by: owl | last post by:
and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from ZoomHeight.py and someone else's clever print suggestion: ------------------------------------------------- # My Clear extension: clear a window class...
0
7273
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7574
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.