C code to search dBASE IV .dbf file?

C code to search dBASE IV .dbf file?

Post by John M. Calve » Tue, 25 Jan 1994 10:05:06



Can anyone point me to C or other code to search for records in
a dBASE IV .dbf file. It would need to return the record #.
Eventually I would like the search to handle regular expressions
across multiple fields, but simple exact strings in one field
would be a great start. I want to do this to replace a Clipper
function which is deathly slow on a large database file, so the
C will be called from Clipper. Thanks.
--
John M. Calvert, velo-rutionary

 
 
 

C code to search dBASE IV .dbf file?

Post by Tom - Leyl » Wed, 26 Jan 1994 14:45:34




Quote:

>Can anyone point me to C or other code to search for records in
>a dBASE IV .dbf file. It would need to return the record #.
>I want to do this to replace a Clipper
>function which is deathly slow on a large database file, so the
>C will be called from Clipper. Thanks.

John:  You can find descriptions of the .DBF structure in a number of books
and can relatively easily write your own routines in C to access a .DBF file
which is (for all intents and purposes) a fixed-length data record with a
header record tacked on the front...

The important points however are : 1) it isn't a dBASE IV .DBF file but rather
a Clipper .DBF file.  dBASE IV has a float datatype I believe (or whatever one
was added) and it might be represented differently in the .DBF file. 2) Clipper
permits "very long strings" because it usurps the decimal length field in the
header to maintain the length (there can't be a decimal place in a character
field).

Unless you're willing to do a lot of extra work your indexes will not be
maintained and you'd have to add record locking code and logic to handle the
contention problems (if this was ever networked).

In other words your routine would be likely to be deathly slow also if you
properly handled the delete flag, update the update flag in the header and
verify the disk writes.

You can write for the RDD guide from CA which would probably help you out in
developing something that enters through the front door...

tom
formerly of Nantucket but so formerly that it probably doesn't bear mentioning
at this late date

 
 
 

C code to search dBASE IV .dbf file?

Post by ?'? » Fri, 04 Feb 1994 00:51:22




>>Can anyone point me to C or other code to search for records in
>>a dBASE IV .dbf file. It would need to return the record #.

Try CodeBase 5.0. It will even allow you to select
the file-locking protocol depending on the database
you are using.

Regards,