Jump to content

Writing to the end of DBF files


Recommended Posts

Hello AutoIt world,

I am embarking on quite a complicated project.  I work in POS systems and we sell a system that uses DBF files to store all of it's data.  What I am trying to do is create an import tool that can append new items to the end of the file list.  I am able to edit the files manually which works, and I know which files to edit.  I have looked around and while there is plenty of code out there about reading and writing DBF files, but nothing I've found seems to allow you to just append to the end of the file without overwriting existing data.  Perhaps I'm looking at it all wrong but I'm not sure.

Does anyone have any ideas on where I could start with this?  Thanks in advance!!

Link to comment
Share on other sites

You can do it all in AutoIt arrays with Xbase I/O, or you can:

  • remove EOF marker in target dbf file
  • append the new records with binary copy (needs to have the same fields structure) + new EOF marker (if not already present)
  • edit the number of records counter in the header (see header struct definition in UDF)
Link to comment
Share on other sites

@RTFC, thank you!  I actually did download your UDF, but I couldn't figure out how to make it work, heh...i didn't realize that the files had EOF markers in them already...is this something that your script just knows about?  I'm still pretty new to the whole DBF structure thing.

Thanks for the advice!!

Link to comment
Share on other sites

@Danp2, I certainly agree that it's the best tool!  I'm just trying to think of ways to automate parts of our process.  The POS program that utilizes these files keeps information about menu items in 3 separate DBF files.  While I could go through and manually add the items, it's a slow, painstaking process that I think could hugely benefit from automation.  So if I could find a way to have an interface with those files through AutoIt, that would be awesome.

I'm thinking of, for example, an Excel spreadsheet with all the item information in one place, and then AutoIt takes those columns of information and appends them to the ends of the appropriate files.  I don't know if this might be a little too complicated for AutoIt.

Link to comment
Share on other sites

1 hour ago, maloysius said:

I'm thinking of, for example, an Excel spreadsheet with all the item information in one place, and then AutoIt takes those columns of information and appends them to the ends of the appropriate files.  I don't know if this might be a little too complicated for AutoIt.

I believe it would be less complicated and potentially more reliable if you used Foxpro to automate this process instead of Autoit. If you stored the changes in a DBF table, then you could write a simple PRG to perform the update.

If you insist on using Excel, this could still be done within Foxpro. FWIW, I've used this library to pull data from Excel into a  cursor and then manipulated the data within Foxpro.

Link to comment
Share on other sites

objcreate("VisualFoxPro.Application")
objcreate("VisualFoxPro.Application.9")

With above you can probably create an object within AutoIt to control VFP. Although I feel thats a weird way of doing it.

Don't know ,much about dbf files (last time I used them was more then 15 years ago)

Just within foxpro you could use append from https://fox.wikis.com/wc.dll?Wiki~APPENDFROM

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...