473,799 Members | 3,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question concerning screen control

My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

Please enlighten me, thanks for your time.
Nov 14 '06 #1
10 1749
In <45************ **********@news .mindlink.netKe nneth Lantrip <bo********@cma access.comwrite s:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
If you're *really* talking about standard C, then no. Standard C has no
concept of a "screen".

If you're willing to be somewhat non-portable, your compiler might have
a clrscr() function.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
They're fairly standard, yes. I'd try googling for "ansi escape
sequences."

Or if there is a "curses" package available for your platform, you
might use that.

--
John Gordon "... What with you being his parents and all,
go****@panix.co m I think that you could be trusted not to shaft
him." -- Robert Chang, rec.games.board

Nov 14 '06 #2
Kenneth Lantrip <bo********@cma access.comwrite s:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
No. See the comp.lang.c FAQ, <http://www.c-faq.com/>, question 19.4.

A formfeed character, '\f', will *not* clear the screen on many
systems.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '06 #3
>My question is: Is there a generally accepted way to clear the screen
>and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Not in Standard C. A number of systems have the "curses" library
which deals with this.
>What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
ANSI control codes only work if the serial terminal or emulation
thereof honors them. So if the program is running on a computer
connected to a dialup line, you're out of luck if the guy is dialing
up with an ASR 33 Teletype or some kind of CRT without ANSI codes.
Also, the terminal emulation in the MS-DOS console is pretty crude
and doesn't do ANSI control codes unless you load ANSI.SYS.

The curses library depends on the user telling the library what type of
terminal it is using, and matching it to a description of the control
codes to use, and the library adapts accordingly.

Lots of terminal emulators emulate ANSI codes. If you *must* hardcode
escape sequences, those are the ones to use. That's not saying much.
>Please enlighten me, thanks for your time.

Nov 15 '06 #4
go***********@b urditt.org (Gordon Burditt) writes:
>>My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

Not in Standard C. A number of systems have the "curses" library
which deals with this.
<OT>
curses is probably overkill if all you want to do is clear the screen.
In some modes of operation, a program that uses curses will restore
the screen's previous contents on exit (though you can probably avoid
that).
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '06 #5
Kenneth Lantrip wrote:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Not within standard C, no. You might try printing a formfeed character,
'\f', or several newlines, but these are all half-baked solutions.
Again, there's no way to move the cursor to a particular line, without
making a lot of unwarrented assumptions.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
They're fairly widespread but are by no means guarenteed to be present.
Please enlighten me, thanks for your time.
If you're program _really_ needs screen control, then using the curses
package is a good option. It's widely implemented across UNIXes,
Windows and Mac. It is a better option than using ANSI control
sequences, which are lower level. Of course, for a specific platform,
often better, more feature-rich libraries are available, but you'll
have to ask such questions in more specific newsgroups.

Nov 15 '06 #6
John Gordon <go****@panix.c omwrote:
In <45************ **********@news .mindlink.netKe nneth Lantrip <bo********@cma access.comwrite s:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

If you're *really* talking about standard C, then no. Standard C has no
concept of a "screen".

If you're willing to be somewhat non-portable, your compiler might have
a clrscr() function.
s/somewhat/more than somewhat/.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

They're fairly standard, yes. I'd try googling for "ansi escape
sequences."
And don't be surprised when people turn that feature off because it can
be used to aggravate, and then tell you that your program looks crap and
leaves random letters all over the screen.
Or if there is a "curses" package available for your platform, you
might use that.
That's probably the solution most likely to work in many places. At
least it has been ported a lot.

Richard
Nov 15 '06 #7
Kenneth Lantrip <bo********@cma access.comwrite s:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Apart from the fact that there's no really portable way to do this,
consider whether you really want to clear the screen. If your
application really needs to take control of the screen (like, say, a
text editor), that's fine, and you probably want to use something
similar to curses. But don't clear the screen just for the sake of
clearing the screen; I don't want *your* program to erase *my*
information without a good reason.

(The fact that you asked about moving the cursor indicates that this
likely doesn't apply to what you're doing, though.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '06 #8
Keith Thompson wrote:
Kenneth Lantrip <bo********@cma access.comwrite s:
>>My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?


Apart from the fact that there's no really portable way to do this,
consider whether you really want to clear the screen. If your
application really needs to take control of the screen (like, say, a
text editor), that's fine, and you probably want to use something
similar to curses. But don't clear the screen just for the sake of
clearing the screen; I don't want *your* program to erase *my*
information without a good reason.

(The fact that you asked about moving the cursor indicates that this
likely doesn't apply to what you're doing, though.)
Thanks guys, You all have been most helpful.

I'll give the \f a try. I just wanted to keep the compiling as simple
as possible. I can already use the ncurses library. I was just trying
to get away from any any extra add-ons to make a simple program work.

For what I am about to attempt I will just use the ncurses. I was just
reaching for something more built in so the program would have greater
chance of being operable accross platforms. Scrolling the screen is
out. There is way too much data that needs to be constantly updated for
scrolling. A simple cursor locating would have been nice, as I wouldn't
have to clear your data first.

Oh well, so goes the wishing.
Nov 15 '06 #9
Kenneth Lantrip wrote:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

Please enlighten me, thanks for your time.
Spamming won't help your cause. You've already been sufficiently
answered from within the topicality constraints of this group. What's
the point in duplicating your original post without specifying further
details or including code?

Nov 15 '06 #10

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

Similar topics

38
5092
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find out what i'm doing wrong, and so far it seems i'm doing it the right way. Here's my code...any suggestions would be appreciated. <script language="javascript"> <!-- window.open("256fx/index.htm", "", "height=400, width=600"); //-->
5
4977
by: Peter Rilling | last post by:
Okay, this method seems simple, but it eludes nonetheless. I have a control that is nested in other controls. Essentially the control is nested several contains from the main form. All I want is to determine the screen coordinates of the control, but if I call RectangleToScreen on either the Form or the parent container results in incorrect bound when passed the bounds of the control. How might I determine the screen coordinates of...
1
1355
by: Green | last post by:
Hi, I have a question concerning how to manipulate the properties in the user control, and there is an interesting article about this from Microsoft: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingpageletproperties.asp My situation is i have a user control resides in the aspx page. And In the aspx page's html, i set the following: <ucl:myControl id="title" EditText="Add New Topic"...
2
1950
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status) to determine what options should be available for this particular item (which is an issue... small issue tracking system). Each of these options is an action that may be performed on the issue and I am dynamically creating LinkButtons for each...
5
1379
by: ken | last post by:
Hi, I have two questions the first is: in the example below how can I call an event from within a statement, such as replace Stop1 with cmdStop1 which is a button on my form? My second question again deals with the example below. Shouldn't I see the valve of " i" counting away in the txtCount1 text box? I don't see anything in the text box and would like to know what I'm doing wrong. Thanks in advance for any and all help. Regards, Ken
9
3184
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
12
2884
by: Boris Borcic | last post by:
Hello, I am trying to use UI Automation to drive an MS Windows app (with pywinauto). I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't get at them). As an alternative to integrating an OCR engine, and since I know the fonts and sizes used to write on the app's windows, I reasoned that I could base a simple text recognition module on the capability to drive MSWindows text...
1
1245
by: mail12211 | last post by:
I can't figure out how to do create this screen. I think I need to use a form with subForm(but I'm not sure). Could you direct me to an article. Or give me some advice on how this is done. I have an apartment building. And I want to record the (tenant payment) checks I put onto my bank deposit ticket. I have 2 tables 1)
8
1837
Stang02GT
by: Stang02GT | last post by:
Hello, I have posted a couple different questions in this thread concerning a menu i had been working on. I have run into another snag in the final stages of the development. I have my current CSS file for my menu(which is posted below), I need to center the menu on the page. My menu starts off at the far left of the screen and spans the whole length of the screen, and i would like to fit under the page heading, since it is quite larger. ...
0
9688
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10030
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.