CLS and LOCATE wouldn't work.

by rpgfan3233 (Login rpgfan3233)

Both would require a terminal-handling library of some sort, such as CONIO on Windows or termcap on Linux. The alternative is to use a curses library which can manipulate terminals, but there is a difference between curses and terminal-handling libraries - curses runs in its own buffer, similar to how you might PCOPY something in QB (PCOPY acts similarly to refresh()/wrefresh() in a curses library). A rough QB equivalent would be:
====
SCREEN 9, 0, 1, 0

PRINT "Hello World!"

PCOPY 1, 0

SLEEP

CLS
====

Not too difficult, right? That's pretty much it, actually. Not very difficult with a curses library. Using something like termcap is a bit different in that you usually need to retrieve and save the user's terminal state, do whatever you need to do, then set things back the way they were before the program started if necessary. However, CONIO isn't difficult at all:
====
PRINT "Hello World!"

SLEEP

CLS
====

Curses is portable (ncurses for non-Windows or PDCurses for Windows and others), but CONIO (Windows) and termcap (non-Windows) are not. Also note that a curses library makes use of curses functions rather than the standard C library functions. printf() is replaced by printw(), getchar() (usually buffered) is replaced by getch() (unbuffered), etc. With CONIO and termcap, the standard library is still able to be used.

------------------
Waiting patiently for Windows 7, XHTML 2.0, CSS 3.0, PHP 6.0, the ratification of C++0x, and the day that I can code without logic troubles.

Posted on May 24, 2008, 7:08 PM
from IP address 12.208.120.144

Respond to this message   

Return to Index