Del Ventruella wrote:
Thank you very much! Can anyone answer the second question regarding how to
save and load one of these structures of structures?
You don't "save" or "load" the structure, per se. The structure is
simply declared in your application, and it tells your app how to
interpret a block of data. You DO "save" and "load" the block of data.
So, presuming that you have declared a structure called "myStructType",
and you have created a block of memory and have a pointer to it called
"myStructP", and you have an open db to write to, you would do it
something like this...
void SaveData(DmOpenRef db, myStructType *myStructP){
MemHandle recH=NULL;
UInt8 *recP;
UInt16 recIndex=-1; //will save the data in a new record at the
end of the database
RecH=DmNewRecord(db, recIndex, sizeof(myStructType));
if (recH){
recP=MemHandleLock(recH);
DmWrite(recP,0,myStructP, sizeof(myStructType));
}
}
Remember that this will save all the contents of the structure, but if
your structure contains pointers to other data (such as the 'name' part
of my 'SoundDataType' structure) then that other data will not be
saved. It will save the current pointer address, but that will almost
assuredly be meaningless once you try to read the data again at a later
time. You have to save those 'pointed-to' bits of data separately.
Bob
Bob
----- Original Message -----
From: "Robert Moynihan" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[email protected]>
Sent: Saturday, October 08, 2005 8:33 PM
Subject: Re: Structure of structures
Hi Del, sure you can include structures in structures. AFAIK, it's not
a PalmOS thing, but rather a C thing. As an example, here's a quick
sample from one of my apps, where I declare a couple of structs, then
include them in another struct. Note that the large structure contains
my own structures plus the "TimeType" structure as declared by the
PalmOS headers. Bob
FWIW. Bob
typedef struct {
Boolean on:1;
Boolean override:1;
Boolean overrideV:1;
Boolean vibrate:1;
Boolean unused:4;
UInt8 soundType;
UInt16 vol;
UInt16 pause;
UInt16 speed;
UInt16 hz;
UInt16 stime;
char *name;
} SoundDataType;
<snip>
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/