home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
PROGRAM
/
BFAST.ZIP
/
BFAST.DOC
next >
Wrap
Text File
|
1992-03-19
|
12KB
|
416 lines
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bFAST version 1.0
C++ class library for Btrieve file manipulation
Copyright (c) 1992 by Chaolin Chang
Chaolin Chang
34 Bettina Street, Clayton,
Vic., Australia, 3168
Voice: +61 3 565-2360
Fax : +61 3 565-5159
Internet: chaolin@fcit-m1.fcit.monash.edu.au
This library is distributed as is. The author assumes no
liability for any damages resulting from its use.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
COMMERCIAL
----------
This library is distributed as shareware.
Since it is only used for evaluation,
a message "Unregistered bFAST copy" will be displayed on screen
whenever a date file is opened.
You may make copies of it for evaluation and distribution
but if you would like to use the library for your project
you should register it.
The cost is US$36/user. (or A$36 if you are in Australia/N.Z.)
Registered users will receive a disk containing the library without
the "Unregistered bFAST copy" message.
Please feel free to distribute the library. But no charge
should be incurred on the person you distribute the library to.
FILES INCLUDED
--------------
The library included here is compiled by Borland C++ 3.0.
If you are using different compiler, let me know.
I see if I can create a specific library for you.
BFAST.DOC // Documentation
BFAST.LIB // Borland C++ 3.0 library
RDBMS.HPP // where the class Rdbms is defined
FIELD.HPP // where the class Field is defined
BTRIEVE.HPP // where the class Btrieve is defined
DEMO.CPP // demo file
ORDER.DEF // demo field definition file
ORDER.DAT // demo order data file
ORDER.HPP // demo field symbol file
DEMO.EXE // demonstration program
BROWSE.CPP // demo of browse
BROWSE.EXE // browse demo program
WHAT IS bFAST?
--------------
bFAST is not developed to meet the market needs.
Instead, it is here because I need such a library for my project.
My project has 10+ executable files and 100+ source files.
This small library works fine for my project.
So, I think it should work for your project as well.
This library, by no means, has included all the functions offered by Btrieve.
Yet, it is sufficient for almost any project.
Given that you are not using transaction or external index.
If you happen to use those functions not included.
Luckily, now we are in the world of C++.
You can easily create a derived class from the class Btrieve to do whatever
bFAST has not implemented.
bFAST has the following class hierarchy
Rdbms Field
└─────┬──────┘
Btrieve
If you like, you can use the base class Rdbms to derive another class
for accessing Xbase files. In this way, you will be able to access
different data files using the same source code.
I would like to share bFAST with anyone who is interesting in it.
Any of your comments will be greatly appreciated.
--------------------------------------------------------------------------
To use bFAST is simple, just follow the 4 steps below.
4 STEPS TO USE bFAST
Step 0 - acquire rdbms.hpp field.hpp btrieve.hpp bfast.lib
Step 1 - create file definition file *.def
Step 2 - create field symbol file *.hpp
Step 3 - include bFAST.LIB in your project file
Step 0
I assume that you know where to put the *.hpp file and *.lib file.
Therefore, let's skip the step 0.
Step 1
CREATE FILE DEFINITION FILE *.DEF
structure for each field
typedef struct
{
char* FldName; // field title
char FldType;
int offset;
int FldLen;
}Field;
Eg. contents of a .def file
#include "field.hpp"
#define ORDER_FIELD 17
Field cord[]={
{"Order Reference" ,'c',0 ,13},
{"Customer" ,'c',13 ,13},
{"Date Ordered" ,'c',13+13 ,9 },
{"Note" ,'c',13+13+9 ,49},
{"Open/Close" ,'c',13+13+9+49 ,2 },
{"Customer branch" ,'c',13+13+9+49+2 ,13},
{"Time Ordered" ,'c',13+13+9+49+2+13 ,9 },
{"Personal contact" ,'c',13+13+9+49+2+13+9 ,21},
{"Service type" ,'c',13+13+9+49+2+13+9+21 ,13},
{"Contract reference",'c',13+13+9+49+2+13+9+21+13 ,13},
{"Sales tax number" ,'c',13+13+9+49+2+13+9+21+13+13 ,13},
{"Customer account" ,'l',13+13+9+49+2+13+9+21+13+13+13 ,4 },
{"Salesman" ,'c',13+13+9+49+2+13+9+21+13+13+13+4 ,13},
{"Sales area" ,'c',13+13+9+49+2+13+9+21+13+13+13+4+13 ,13},
{"Sales code" ,'c',13+13+9+49+2+13+9+21+13+13+13+4+13+13 ,13},
{"Deduct forecast" ,'c',13+13+9+49+2+13+9+21+13+13+13+4+13+13+13 ,2 },
{"Text" ,'c',13+13+9+49+2+13+9+21+13+13+13+4+13+13+13+2,59},
};
Step 2
CREATE FIELD SYMBOL FILE *.HPP
The field symbol file is used to accessed a field, either
replace the contents of a field or retrieve the contents of a field.
You can find example in the end of the function lists.
eg. contents of a .hpp file
#define ORDER_REFERENCE 0
#define CUSTOMER 1
#define DATE_ORDERED 2
#define NOTE 3
#define OPEN_CLOSE 4
#define CUSTOMER_BRANCH 5
#define TIME_ORDERED 6
#define PERSONAL_CONTACT 7
#define SERVICE_TYPE 8
#define CONTRACT_REFERENCE 9
#define SALES_TAX_NUMBER 10
#define CUSTOMER_ACCOUNT 11
#define SALESMAN 12
#define SALES_AREA 13
#define SALES_CODE 14
#define DEDUCT_FORECAST 15
#define TEXT 16
FUNCTION LISTS
--------------------------------------------------------------------------
//
// after any function call, you can always use
// Err()
// to check if the operation is successful.
//
Open a file
Btrieve(char* path, char *filename,Field xfld[],int fldNo,int keyNo=0);
eg.
Btrieve f("", "ORDER.DAT", cord, ORDER_FIELD);
This statement open file ORDER.DAT in current working directory.
Its field definition is defined in cord.
It has ORDER_FIELD number of fields.
The defualt key is used, whihc is key 0.
Btrieve f("C:\\DAT", "ORDER.DAT", cord, ORDER_FIELD);
this statement open file ORDER.DAT in directory C:\DAT
Deconstructor
~Btrieve();
~Btrieve will automatically close a file
--------------------------------------------------------------------------
FILE STATUS
-----------
Get the file name
char* FileName(void);
Get the current working directory
char* Path(void);
Return the error code
int Err(void);
Length of a index key
int KeyLength(int keyNo);
int KeyLength(void);
Index key currently used
int IndexNo(void);
Change index key
int UseIndex(int key=0);
Current index key value
char * KeyValue();
Length of record buffer
int DataLen(void);
Open a file (internal use)
int Open(void);
Close a file
int Close(void);
Check if end of a file
int Eof(void);
Check if beginning of a file
int Bof(void);
Check if a empty file
int Empty(void);
Unlock a record
int Unlock(void);
----------------------------------------------------------------------------
RECORD ACCESSING
----------------
Indexed file
Get the first record
int GetFirst(int lock=0);
Get the record which the key is equal to specified value
int GetEqual(char* keyvalue, int lock=0);
Get the last record
int GetLast(int lock=0);
Get the next record
int GetNext(int lock=0);
Get the previous record
int GetPrev(int lock=0);
Get the record which the key is greater or equal to a specified value
int GetGEqual(char* keyvalue, int lock=0);
Get the record which the key is greater to a specified value
int GetGreater(char* keyvalue, int lock=0);
Get the physical position of current record
long GetPost(int lock=0);
Go to specified physical position
int GoTo(long,int lock=0);
Sequential file
---------------
Get the first record
int StepFirst(int lock=0);
Get the last record
int StepLast(int lock=0);
Get the next record
int StepNext(int lock=0);
Get the previous record
int StepPrev(int lock=0);
--------------------------------------------------------------------------
FILE UPDATION
-------------
Rewrite the record
int Rewrite(void);
Inser a new record
virtual int Write(void);
Delete the current record
int Delete(void);
--------------------------------------------------------------------------
FIELD MANIPULATION
------------------
//
// In field manipulation, every field can be referenced either by
//
// 1. using its field name, which is defined in the structure Field
//
// eg.
// f.fReplace("Order Reference", "123456789012");
//
// 2. using its relative position from the first field, which is defined
// to zero.
//
// eg.
//
// #define SALES_ORDER_REF 0
// #define CUSTOMER 1
//
//
// f.fReplace(SALES_ORDER_REF, "123456789012");
// f.fReplace(CUSTOMER, "ABC Co.");
//
//
UPDATE A FIELD
--------------
//
// All fReplace() return
// 1 - successful
// 0 - error
//
Replace a string field
int fReplace(int ,char * );
int fReplace(char* ,char * );
Replace an integer field
int fReplace(int ,int );
int fReplace(char*,int );
Replace a long field
int fReplace(int ,long );
int fReplace(char*,long );
Replace a float field
int fReplace(int ,float);
int fReplace(char*,float);
Replace a double field
int fReplace(int ,double);
int fReplace(char*,double);
GET THE CONTENTS OF A FIELD
---------------------------
//
Get every type of field in string format
char* fStr(int i=0, const char *ptemplate="%s");
char* fStr(char * str, const char *ptemplate="%s");
eg.
#define SALES_ORDER_REF 0
#define CUSTOMER 1
char salesOrder[13];
strcpy(salesOredr, f.fStr(SALES_ORDER_REF));
or
strcpy(salesOredr, f.fStr("Order Reference"));
Get a character field
char fChar(int);
char fChar(char * );
#define ORDER_REFERENCE 0
#define CUSTOMER 1
#define DATE_ORDERED 2
#define NOTE 3
#define OPEN_CLOSE 4
if (f.fChar(OPEN_CLOSE)=='Y')
...
Get an integer field
int fInt(int);
int fInt(char * );
Get a long field
long fLong(int);
long fLong(char * );
Get a float field
float fFloat(int);
float fFloat(char *);
Get a double field
double fDouble(int);
double fDouble(char *);