Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable length Fields

Status
Not open for further replies.

Shaga

Programmer
Apr 1, 2003
11
0
0
GB
Hi again,

I am attempting to read in records from a Btrieve v6.15 file. I can get to the records ok, and have worked out the structure, but the problem seems to be that the FIELDS are variable length. Is this possible in Btrieve? I have set fixed length Fields in my data structure which Btrieve passes the field values into. I get the header ok and the first variable length field, but then the rest of the fiedls are not correctly offset, so I end up either with no data in the particular field or part of the data (all strings by the way) or part of a field in the wrong field!

Help!!!
 
Some developers used the variable length field to store several fields. And they used zstring or lstring field types which can be packed togeather. The problem is that you cannot use DDF files for these fields as they change position from record to record. The only way to get data out is by writing a program to parse the fields out.
Gil
 
Can you give me an example of the code, either C++ or .NET but VB6 would be ok as well.

Cheers
 
You can take a look at BtSearch at to help you analyze the structure. As far as code it would depend on what type of data is stored in the variable length portion of the file. Your best bet is to try and get the devloper to provide some of the details.
Gil
 
The first thing to do is run a BUTIL -STAT against the file and find out the fixed record length, and match that up with your record structure in your application. All of the data in the fixed length portion is just that - fixed.

If the data is coming into your buffer shifted for certain fields, you're probably having a Byte Alignment issue. Most compilers default to a word or double word byte alignment for structures, which means extra bytes are thrown in by the compiler to keep integer fields on even boundaries. Most compilers (except for VB) allow you to specify an alignment option, and you need it to be set to single byte for Btrieve. You can do it for the entire app, or for the individual structures used in Btrieve calls.

If you search the Pervasive KB for "alignment" you'll find a couple articles on this topic, including info on dealing with this in the VB environment.

When you do your BUTIL -STAT, you'll also see a Variable = Yes or No option. If it's set to Yes, then your Btrieve file supports a variable field at the END of your fixed length record. The amount of data in the variable field will vary from record to record. If you search the KB on "Accessing Variable Length Btrieve Files" you'll get a technical paper that describes this in much more detail.

Linda
Linda
Pervasive Software Support
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top