Variable length Fields
Variable length Fields
(OP)
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!!!
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!!!
RE: Variable length Fields
Gil
RE: Variable length Fields
Cheers
RE: Variable length Fields
Gil
RE: Variable length Fields
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