Dec 062017
 
Freeware C/C++ library for accessing Btrieve files.
File BFAST11.ZIP from The Programmer’s Corner in
Category C++ Source Code
Freeware C/C++ library for accessing Btrieve files.
File Name File Size Zip Size Zip Type
BFAST.DOC 12878 3939 deflated
BFAST.LIB 18432 5796 deflated
BROWSE.CPP 18966 3574 deflated
BROWSE.EXE 96060 43068 deflated
BTRIEVE.HPP 5994 1390 deflated
DEMO.CPP 1567 658 deflated
DEMO.EXE 36392 19906 deflated
FIELD.HPP 481 245 deflated
ORDER.DAT 4096 212 deflated
ORDER.DEF 1577 380 deflated
ORDER.HPP 842 298 deflated
RDBMS.HPP 3027 581 deflated

Download File BFAST11.ZIP Here

Contents of the BFAST.DOC file


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bFAST version 1.1
Wed 09-09-1992

C++ class library for Btrieve file manipulation

Copyright (c) 1992 by Chao Lin Chang

Chao Lin Chang
34 Bettina Street, Clayton,
Vic., Australia, 3168

Voice: +61 3 565-2360
Fax : +61 3 565-5159

Internet: [email protected]

This library is distributed as is. The author assumes no
liability for any damages resulting from its use.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
!!README FIRST!!

After months of thoughts, I decide to release bFast 1.1 into
public domain. I would like to share it with you.

You are FREE to use it any of your applications, provided
you would kindly inform me that.

Though it is FREE, it is fully functioning. No trick, no nagging
message. It is the same code I used to write my app.

No much is changed in the C++ part. I only did some patch up
and add a new function to return the number of records.

However, in this release I include some of my old
routines written in C, compiled in C++ though.

Following is the function prototype. You can use of course, but
I would not recommend it.

// ------------------------------------------------------
// btrieve function
// ------------------------------------------------------
int b_reset(void);
int b_begin(void) ;
int b_end(void) ;
int b_abort(void) ;
int b_close(char *unit);
int b_unlock(char *unit);
int b_read(char *unit,int key_num,int op_num,void *key_value,void *key_buf);
int b_create(char *file,int key_num,void *key_buf);
int b_stat(char *unit,void *data_buf, char *key_buf);
int b_write(char *unit, int key_num, void *key_buf);
int b_rewrite(char *unit, int key_num, void *key_buf);

Also one thing now I am working on is to allow bFast to read data
structure from DDF files (created by Xtrieve). So the data
structure need not to be hard-coded.

THANKS FOR YOUR ATTENTION.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
2 int Bof(void);

Check if a empty file
int Empty(void);

Unlock a record
int Unlock(void);

Count the Number of records in file (new)
long RecCount();

----------------------------------------------------------------------------
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 *);



 December 6, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)