12 Programs with functions
This chapter has a few examples that show some of the things that you can do using
functions and arrays. A couple are small demonstration programs. Some, like the first
example are slightly different. These examples– "curses", "menus", and "keywords" –
entail the development of useful group of functions. These groups of functions can be
used a bit like little private libraries in future examples.
Yes, well programs and curses are strongly associated but this is something
different. On Unix, there is a library called "curses". It allows programs to produce
crude "graphical" outputs using just low "cost cursor addressable" screens. These
graphics are the same quality as the character based function plotting illustrated in
10.11.2. Unix's curses library is actually quite elaborate. It even allows you to fake a
"multi-windowing" environment on a terminal screen. Our curses are less vehement,
they provide just a package of useful output functions.
These functions depend on our ability to treat the computer screen (or just a single
window on the screen) as a "cursor addressable terminal screen". Basically, this means
that this screen (or window) can be treated as a two-dimensional array of individually
selectable positions for displaying characters (the array dimension will be up to 25 rows
by 80 columns, usually a bit smaller). The run-time support library must provide a
gotoxy() function and a putcharacter() function. Special character oriented input
functions must also be used.
Such facilities are available through the run time support libraries provided with
Symantec C++ for PowerPC, and Borland's IDE. In the Borland system, if you want
cursor addressing facilities you have to create your project as either a "DOS Standard"
Run-time support in
Programs with functions and arrays
project, or an "EasyWin" project (there are slight restrictions on EasyWin and cursor