{$X+}
{
DBBASE III+ Support component by Daniel Parnell
I wrote the following code over a couple of hours because I noticed that
people were complaining in comp.lang.pascal (usenet newsgroup) that to use
any data base files in their applications made their resulting programs huge.
So, I grabbed my Delphi books and had a go at creating a DBASE III+ unit, and
here is the result.
Now for the legal stuff. Anybody can use the following code for anything
that they want. I would however like to be notified of any use this code is
put to because I'm interested in seeing what is done with it. Credit would
be nice also.
Note: These routines ignore the record deletion flag.
Daniel
[email protected]
}
unit DBase3P;
interface
uses Classes;
const
MaxSize = $7FFF; { Size of the record buffer }
maxFields = 16; { Maximum number of fields }
type
TBigArray = array[0..MaxSize] of char;
PBigArray = ^TBigArray;
THeader = record
version : byte; { Should be 3 or $83 }
year,month,day : byte; { Date of last update }
numRecs : longint; { Number of records in the file }
headLen : word; { Length of the header }
recLen : word; { Length of individual records }
rez : array[0..19] of byte; { reserved }
end;
TField = record
name : array[0..10] of char; { Name of the field }
what : char; { Type of data in this field }
data : array[0..1] of word; { Not used }
len : byte; { Length of the field }
places : byte; { Number of decimal places }
rez : array[0..13] of byte; { Reserved data area }
end;
TDBase3Plus = class(TComponent)
private
FfileName : string; { Name of the DB file }
fileOpen : boolean; { TRUE if the file is open }
DBfile : file; { The actual file }
buffer : PBigArray; { Temp buffer for record }
procedure SetFileName(name : string);
protected
public
cRecord : longint; { Current record }
about : THeader; { Info about the file }
numFields : byte; { Number of fields in the file }
fields : array[1..maxFields] of TField; { The field data }
rec : array[1..maxFields] of string; { Record data }
constructor Create(AOWner : TComponent); override;
destructor Destroy; override;
procedure Close; virtual;
procedure Open; virtual;
procedure write(r : longint); virtual;
procedure Seek(r : longint); virtual;
procedure NewRecord; virtual;
procedure GotoStart;
procedure GotoEnd;
procedure GotoNext;
published
property FileName : string read FfileName write SetFileName;
end;
procedure Register;
implementation