[Tutor] CLS? (Joseph Quigley)

Alan Gauld alan.gauld at freenet.co.uk
Sat Apr 23 21:02:45 CEST 2005


> Drat. I do like the \n * 100 though but that really wasn't what I
was
> getting at. Do you know what the command is for Mac

The problem is that it depends not just on the OS.

MacOS X is Unix and that can support zillions of different terminal
types each with their own control codes. These are mapped to a
standard set in a database called (depending on your Unix version!)
terminfo or termcap (cap=capability) and manipulated by a utility
called tty. The difficulty is that not all terminals support all
capabilities so you have to call stty to first find out if the
capability exists, then use stty again to set it. - Altogether
far too messy for most mortals.

The more common route on Unix is to use the curses library which
provides a windowing toolkit for a dumb terminal. The default
window is the whole screeen and curses allows you to position the
cursor at any point on screen, clear the screen(Or any rectangular
section of it) and so on.

Try man terminfo for the full story, and man curses if you want
to go down that route. Programs like vi and top are written using
curses.

> considering not clearing the screen. What a hassle.

As someone else said thats actually the right approach on a Unix box.
Consider that some folks might be using an old paper teletype where
the text just prints onto paper which scrolls off the top. What
happens
with my print '\n'*100 there? - they get a lot of white paper!

Now on DOS MIcrosoft used a thing called the ANSI terminal which is
a kind of virtual terminal standard that a lot of terminal
manufacturers
could support in addition to their own standards. It was pretty dumb
but by adopting a standard QBASIC et al could implement screen
controlls
in assembler so they were both fast and reliable. But it only workled
because the PC only supported that one standard.

The joys of multi platform computing! :-)

Alan G.



More information about the Tutor mailing list