Solved

Sample C code using CODEBASE  for reading .DBF file  requested please

Posted on 2008-10-30
6
1,031 Views
Last Modified: 2013-11-24
I have an inherited MS C development environment which I usually use for reading Btrieve files and writing out to dBase (.dbf) files; this is done by a prewritten function extractToDbase which uses Codebase.

I now have a need to read in one of these DBF files, update a field, then write out a new dbf file.

Unfortunately there is no prewritten function supplied for reading dBase files, my "skills" are no where near good enough for me to write one, and I can't find any Codebase manuals anywhere (locally or on the net).

Ideally I'd like to read in the dbf file using Codebase, but an alternative would be to unload the file to text first; either needs to be coded in C.

I would be very grateful if someone could post some sample code. Once I've got the gist of it, I should have no problem amending it to what I need.

Many thanks,
Rob
0
Comment
Question by:RClack
  • 4
  • 2
6 Comments
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 120 total points
ID: 22840773
Hi Rob,

It's not even that easy.  :(  There are several different formats for DBF files.  Competing products used the extension but had somewhat different formats.  Within a product line, a DBF file written for one version of the software is often incompatible with other versions.

What do you do with the DBF file once it's created?


Kent
0
 

Author Comment

by:RClack
ID: 22841430
Hi Kent,

The file is sent to users and probably viewed in Excel.

To give more indication on the format of the files, whenever I need to manually update these files I either use the dbu utility or I amend in Excel and then Save As DBF 3 (dBase III).

ROb
0
 

Author Comment

by:RClack
ID: 22841528
Hi Kent,

The file is sent to users and probably viewed in Excel.

To give more indication on the format of the files, whenever I need to manually update these files I either use the dbu utility or I amend in Excel and then Save As DBF 3 (dBase III).

If I can get started with the syntax then I'm hoping everything else will fall into place.

Rob

PS  "Ideally I'd like to read in the dbf file using Codebase, but an alternative would be to unload the file to text first; either needs to be coded in C."  Yes, I've just realised how silly that sounds as obviously I need to read the file in either situation!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:RClack
ID: 22841800
I've read elsewhere that I could read it byte by byte as the dBase structure is published and relatively straight forward, so I guess that's another angle I can explore....
0
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 120 total points
ID: 22842149
This is going to be more than you wanted,  :),  but here's a DBF format description that should cover you.


http://www.clicketyclick.dk/databases/xbase/format/dbf.html#DBF_STRUCT


Kent
0
 

Accepted Solution

by:
RClack earned 0 total points
ID: 22842857
Thanks Kent,
I've come across several already but I like the way they have laid it out on that one!

I have come across a C program that I think I'll be able to amend to my purposes; see ftp://ftp.mpoli.fi/pub/software/PROGRAMM/C/DBASE.C, though my proxy would only allow me to view it through Google cache!

I'll come back to this on Monday to see if anyone actually comes back with some Codebase C coding, but I'll def award you points anyway for taking the trouble to help out.

Cheers,
Rob
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now