Author: | Eric Aling (03 okt 2000) |
Accessed: |
Download: | ( dbf.zip 17Kb ) |
You already can import DBF (dBase) files into your datawindow using the importfile() function. Howver, the definition of the datawindow must match he DBF record layout. Okay, no problem. Using an ODBC driver yuo can easily create the datawindows on the fly by using the SyntaxFromSql() function. This is all very simple but what if you don't have an ODBC driver or you are not allowed to use one. In that case, you have to do this manually, which can be very unhandy if you don't know the DBF recordlayout. Especially if you have more DBF you want to use, it's a load of work.
To circumvent this, I have created a DataStore object that creates a dataobjects in this datastore just by specifying the name of an existing DBF file. A DBF file is nothing more that a flat file, where the first part is the header (32 bytes) and column descriptions (each 32bytes) followed by the data. So, what this object does is examine the header and column descriptions. With this information, dataobject syntax is generated and from this syntax the dataobject is created withing this datastore. After that, an importfile() is processed to import the data from the DBF file.
Check out the PB7 example accompanied with a DBF file and see how beautiful this works.