Final Project: Name and addressbook


The final project is a Rolodex-style name and addressbook program. This program will incorporate a majority of the data structures and techniques covered in class.

The user must be able to add, edit, and delete names from the Rolodex program. This program will also incorporate colorful and attractive user interface, but will remain a text-based console application. Screen items likes menus, fields, and status messages will be implemented.

Throughout the semester, you will be given portions of code to help finish the project. You will primarily be responsible for taking the supplied code, understanding it, implementing it into your own program, and creating the final program.

90% of this project will contain re-usable code. The screen I/O routines will be specific to Intel platforms, and therefore non-ANSI C functions. The Intel-specific code will be provided to you, and discussed in a cursory fashion during class.

The following items are an outline of functions and capabilities with a general overview of how to accomplish them. It should be noted that each of these steps represent a stage in project development as well as function development, each stage (once completed) is added to the actual project until the entire program is completed. At the end of ech stage, you should be able to write a small test program for your new code.

Stage 1: Data Input and Output
A set of low-level screen input and output functions will need to be written for data input and later screen-input stages. These functions Include:

	void CPrintChar( int Char, int Color );
	void CPrintStr( char *Str, int Color );
	void Locate( int Row, int Col );
	void HideCursor();
	void CursorOn(void);
	void GetLocation( int *Row, int *Col );
	void Cls( int Color );
	void ClearRect( int Row, int Col, int Height, int Width, int Color );
	int GetStr(char *Dest, int Len, int EColor, int RColor, int Options);
	void At( int Row, int Col, char *Str , int Color );

Stage 2: Screen Painting
Using the functions from stage 1, a family of generic screen functions will need to be developed such as:

	void DrawData( FIELD *Fields, int Row, int Col, int Color);
	void DrawLabels( FIELD *Fields, int Row, int Col, int Color);
	int EditData( FIELD *Fields, int Row, int Col, int EditColor, int RegColor);

These functions will utilize a data structure similar to the following, usually use in an array:

typedef struct _tagFIELD {
	int Row, Col, Length, Option;
	char *Dest, *Label;

This stage will complete a re-usable portion of screen-painting code for a variety of data-entry purposes. Screen-painting designs may be implemented as arrays of the above structure.

Stage 3: Menuing
Using the low-level I/O routines from stage 1 again, a fundamental menuing system will be created. The functions for this section will be a single 'Menu' function, and 2 support functions. This menu will support sub-menus, hot-keys, and be based on a 'call-back function' principle, using function pointers. The functions are:

	void DrawMenu(  MENUITEM MenuList[], int Row, int Col, int RegColor, int HiColor, int Item );
	void ClearMenu(  MENUITEM MenuList[], int Row, int Col, int Back );
	int Menu( MENUITEM MenuList[], int Row, int Col, int RegColor, int HiColor, int Back, int AllowEsc );

The structure to be used for these functions will be:

typedef struct _tagMENUITEM {
	char *Selection, *Description;
	int HotKey, ID;
	int (*Func2Call)(int);	// Pointer to function to invoke, or...
	struct _tagMENUITEM *Menu2Call; // Pointer to sub-menu


Stage 4: File I/O
This stage will implement the actual person-information structure, and several file-access routines used to read and write that structure to disk. Functions developed will be similar to the following:

typedef struct _tagDATAFILE {
/* Really a FILE *, but this way the FILE define is not needed for all modules */
	void *Stream; 
	unsigned int RecordSize, RecordCount, RecordNum;
	NODE *CurList, *CurNode;
#define GetCurRec(f) (f->RecordNum)
#define DB_DELETEDOK 0x0001
int GetOperatingStat(void);
int SetOperatingStat( int Stat);
DATAFILE *OpenDataFile( char *File, int BufferSize );
void CloseDataFile( DATAFILE * File );
int ReadRecord( DATAFILE *File, void *Dest );
int WriteRecord( DATAFILE *File, void *Dest );
int AddRecord( DATAFILE *File, void *Dest );
int GotoRecord( DATAFILE *File, unsigned int RecordNum );
int FirstRecord( DATAFILE *File );
int NextRecord( DATAFILE *File );
int PrevRecord( DATAFILE *File );
int IsDeleted( DATAFILE *File, unsigned int RecordNum );
int IsTaggedDeleted( DATAFILE *File, unsigned int RecordNum );
int DeleteRecord( DATAFILE *File );
int MatchRecToLL( DATAFILE *File, NODE *Cur, int Err );
int FindKeyRecord( DATAFILE *File, char *Key );

This stage starts to implement application-specific code such as record layout and size. It should still be a design principle to make the code easy to change for other database applications. The Linked-list attributes such as Next and Previous record pointers are NOT part of this stage OR the person data structure.

Please note: Based on class progress, the expectations of this stage may be cut down in terms of re-usability, but not ability. In other words, you will still need to read and right records to a file, whether we design a data structure and support functions for it or not will be decided later.

Stage 5: Linked List management
This stage will utilize the linked-list data structure to maintain the records in a lastname order. Once this stage is completed the file I/O routines from stage 4 will be modified to use the linked list for ordered data retrieval. Functions include:

CreateList(), AddData(), FindData(), FirstData(), NextData(), PrevData(), LastData(), DeleteData(), and

The linked-list developed must be re-usable. The linked-list code will not be tied to the person structure directly, but will be maintained by functions.

For the database, when the application is started, the linked list(s) is created, and each record from the data file is read into memory. Each record is then added to the linked list. At the end of the program run the linked list is removed from memory.

Stage 6: Completion
Extensive testing, debugging, and usage are required to fine-tune the project to not only give it a professional look, but also ease of use. Each application should be considered 'bullet-proof' and free of bugs.

Stage 6 is of course the last step. Source code and data structures for the early stages of the final project will be made available later in the semester, but the student should work on their own implementations as soon as possible, or when discussed in class. The later stages (4-6) of the application will be developed and demonstrated, but will not be provided to the student in the entirety.

Top-down programming
At certain stages of development, a top-down approach works well. In top-down programming, the programmer considers the overall operation of a program or function without actually worrying about the small details of operation. Once the overall design is complete, the programmer may start to work on the small detailed support functions. An exaggerated example is a program that has a menu. The programmer would first write:


Next, they would work on the menu function:

	do {
		if( Ch==CURDOWN)
		else if (Ch==CURUP)
		else if (Ch==ENTER)
	} while (Ch != ESC );

Next, the programmer would further break down each of the above detailed functions. And so on.