As already pointed out, you can't write pointers to records in your PDB
file. Another way to simplify writing and reading the structure is to use a
fixed size for your character string members and write the whole structure
as a record.
try:
Struct Rec {
int foo;
char bar[LengthNeededforbar];
};
...
newRec = DmResizeRecord(db, index, sizeof(rec));
// Fill in your field values here
errDb = DmWrite(MemHandleLock(newRec), index, rec, sizeof(rec));
Now, if you need a variable size for bar, then you will have to continue to
write the values of each element in your structure into the record. There
are plenty of methods that don't require you to use delimiters between
fields but delimiters can help.
----- Original Message -----
From: "Steve K" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 6:46 PM
Subject: Database help.
> The way I am currently using the palm database does not seem correct.
> Yes I have gotten it to work, and it is doing what I ask it to do,
however,
> It seems WAY too complex and there has to be a better way.
>
> Currently I keep my information in a struct Rec
>
> For example:
>
> Struct Rec {
> char* data;
>
> int foo;
> char* bar;
> ... constructor destructor etc...
> };
>
> When I write to the record I am writing Rec.data, which is a char star
with
> each field seperated by "~"'s.
> For example if foo is 5 and bar is "asdf" then data would be "5~asdf"
>
> When I pull the data out of the DB I put it into a new rec's data field.
>
> I then have two functions, CombineDataIntoFields and ExpandData. This
fills
> the appropriate fields, foo and bar, with the data out of data, or vice
> versa, creates data by concating all the fields with the "~" spacer.
>
> Like I said, WAY too complex.
>
> I have tried just writing a pointer to a record this way:
> Struct Rec {
> int foo;
> char* bar;
> };
> // rec is a *Rec
> newRec = DmResizeRecord(db, index, sizeof(rec));
> errDb = DmWrite(MemHandleLock(newRec), index, rec, sizeof(rec));
>
> I know there has to be a way to do something like this but it isn't quite
> working yet.
>
> Any suggestions?
>
> tia,
>
> Steve K
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/