×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Variable length Fields

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!!!

RE: Variable length Fields

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

RE: Variable length Fields

(OP)
Can you give me an example of the code, either C++ or .NET but VB6 would be ok as well.

Cheers

RE: Variable length Fields

You can take a look at BtSearch at www.nssdd.com 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

RE: Variable length Fields

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close