Chrix Bell wrote:
I have make a struct with two offsets and a "take-place" field
looks like this:
struct whatever{
unsigned Aoffset;
unsigned Boffset;
char FirstField;
}
I want to use this to pack the record size,
What does "pack the record size" mean?
data would be write from
FirstField, write A, then from (FirstField+ Boffset), write B.
What are "A" and "B"? Are the some sort of data you want to write
into a database? Are they variables? Are they instances of
"struct whatever"?
And I use dmWrite() to fill data into this struct, but returned
"out of bound".
This could easily happen if you created an instance of the struct
with MemPtrNew() or on the stack. DmWrite() only should be used
to write into the storage heap, which usually means writing directly
into a record within a database.
I am wondering if there are some other kind of skills can make
the record's length not a fixed one.
If by "the record" you mean the struct, then it is impossible.
In C, a struct's size is determined at compile time. If you need
to write a data structure whose length differs depending on what it
contains, you will need to write it by hand, one byte at a time.
(Or with DmWrite() or MemMove() or similar.)
By the way, you might get more useful answers if you explain what
you're trying to do, i.e. what problem you're trying to solve.
I can't really tell based on your message what you're trying to
accomplish with this struct you've defined.
- Logan
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/