                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             DATABASE LIBRARY V1.0

                                      by
                                  Chris Bomar

                               Copyright 1995 by
                        Apocalyptic Dimensions Software

                                 Documented on:
                                 Nov. 11, 1995


























                              
                              TABLE OF CONTENTS:
                              ------------------

Introduction........................................................(1)
Using the Library...................................................(2)
Conclusion..........................................................(5)
Ordering Info.......................................................(6)
Appendix A - Error Codes............................................(7)
Appendix B - Datatypes..............................................(8)



















              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
                                INTRODUCTION    
                                 
The Database Library was compiled in Turbo C++ v3.0.  It should be easily 
portable to other C++ compilers.  This library makes it MUCH easier to 
maintain and manipulate databases.  You can use this library for many
different things such as handling user databases for BBS software or to save 
options in games.  Use your imagination!  This library was created in 
approximately 4 weeks.  It supports just about every datatype and has 
funtions for getting, putting, and deleting records in a datafile.  I hope 
you find this library very useful and time saving.  I know I did!
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (1)

                              USING THE LIBRARY

To use the Database Library include DATABASE.H in your main *.cpp and 
add DATABASE.LIB to your project.  

Constructor:

void database(char *)

Destructor:

void ~database(void)

When initializing the class, you must give the name of the file to open.
EX:

database Database("DATAFILE.DAT")

You can use a variable for the file name.  Each record is divided into
different fields.  The Database Library supports up to 65,535 fields in every
record and 4,294,967,295 records in every datafile.  Suppose you want to   
make a program that stores information for the employees in your company.
You might want the following fields in each record.

Name:
Age:
Phone Number:
Salary:

The record would have 4 fields.  After initializing the class, use 
createField to make the fields. 

int createField(char *)

It accepts a string as a parameter.  The string specifies what datatype this
field is suppose to be.  To create the above fields we would use the 
following code.

createField("STRING");
createField("INT");
createField("STRING");
createField("FLOAT");

They must be created in order.  Name and phone number would be strings so
the parameter would be STRING.  Age is an integer so type INT.  Salary would
be a float so type FLOAT.  All functions return 0 if there are no errors
and a non-zero if an error occured.  Refer to appendix A for error codes.
You can check for an error in every function except for the constructor and
destructor by doing something such as the following.

int errorCode;
errorCode = createField("STRING");
if (errorCode != 0) 
   {cout << "\nError!\n"; exit(1);}

Or if you want it more compact...

              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (2)  

if ((createField("STRING")) != 0)
   {cout << "\nError!\n"; exit(1);}

Refer to appendix B for all possible datatypes.  The datatype string must
be in all caps.  After creating the fields you want, you must initialize the
record structure.  To do this use InitRecord.

int InitRecord(void);

EX:

InitRecord();   // without error checking

if ((InitRecord()) != 0)
   {cout<< "\nError!\n"; exit(1);}    // with error checking

Now the record is locked and you cannot add anymore fields but this function
must be called before you do any manipulations on the datafile.  To put 
data into a field use putField.

int putField(unsigned int, <overloaded>);

The first parameter is the number of the field to put the data into.  The
second is the actual data.  The data being put into a field must be of the
same datatype as the field itself.  You specified this in createField.  
After putting all the data into the fields, call putRecord to write the 
entire record (all the fields) to the datafile.

int putRecord(unsigned long);

EX:

putRecord(1);

This takes all the information in the fields and writes it to record number
one.  To retrieve a record from the datafile use getRecord.

int getRecord(unsigned long);

EX:

getRecord(12);

This gets record number twelve.  To get the information from the fields use
getField.

int getField(unsigned int, <overloaded>);

EX:

getField(2, &number);

The first parameter is the number of the field and the second is a pointer 
to the variable that you want the data to be copied to.  To delete a record
use deleteRecord.
            

              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (3)  

int deleteRecord(unsigned long);    

EX:

deleteRecord(4);

This will delete record four from the datafile.  

Study the example program, EXAMPLE.CPP and EXAMPLE.PRJ on your hard drive,
to see how all this works together in a program.  

















































              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (4)  
              
                                  CONCLUSION

The Database Library is a very powerful class that will save you time and 
head-ache.  Its uses are almost endless!  Anytime your program needs to write
something to disk, the Database Library is probably the thing to do it with.
I have included an example program with source code for you to study.  I
have also included a demonstration program, Latin Pro v1.0, to show you the
power of the Database Library.  Latin Pro is in LATINPRO.ZIP.  Create a
separate directory and unzip it there.  If you have any questions or 
comments, leave me e-mail at:

72774.246@compuserve.com













































              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (5)  
              
                                 ORDERING INFO

If you do not have the registered version of the Database Library, when
you call the constructor you will get a registration message and a delay.
Registration is $8.  When you register you will receive:

The registered DATABASE.LIB  (no message, no delay!)
A laser printed manual
ADSdex v2.0 - Normally $8 but free to you!  Demonstrates the Database Lib.

You also have the option of ordering the source code for DATABASE.LIB.
The source code costs $24.  You will receive all of the above plus the source
code for the Library on disk and the laser printed source code.

To order print ORDER.FRM or run ORDER.EXE and it will be printed for you.

Apocalyptic Dimensions Software makes software of much lower cost than other
program developers.  Just look at the prices above!  How many programmers do 
you think would sell you the source code to something this useful for less 
than $30?



ADS                                 E-Mail:
9916 Harlington St.                 72774.246@compuserve.com
Cantonment, FL. 32533
































              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (6)  

                           APPENDIX A - ERROR CODES



0 - No Errors
1 - Record already initialized
2 - Record not initialized
3 - Field past end of record
4 - Record past end of file
5 - Datatype mismatch
6 - Invalid datatype
7 - Not a datafile













































              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (7)  
              
                            APPENDIX B - DATATYPES



char - STRING
unsigned char - UNCHAR
unsigned int - UNINT
short int - SHINT
int - INT
unsigned long - UNLONG
long - LONG
float - FLOAT
double - DOUBLE
long double - LGDOUBLE









































              
              
              DATABASE LIBRARY V1.0 - by Chris Bomar - Page (8) 
