At 4:14 PM -0600 3/23/01, Richard Burmeister wrote:
>You are free to put whatever you want in each record of your database (up to
>about 64 KB).  If you put in two different structures, you will want to have
>some way to identify the contents so you can later read the data.  One way
>to do this is to use the first member of the structure to identify which
>data is in the record.  For example (warning - uncompiled code just typed
>into this email!):
>
>enum types
>{
>  typeA = 0,
>  typeB
>};
>typedef struct
>{
>  enum types thisType;
>  union data
>  {
>    struct A
>    {
>      Char name[20];
>      UInt age;
>      // etc;
>    } A;
>    struct B
>    {
>      UInt height;
>      UInt weight;
>      // etc;
>    } B;
>  } data;
>} recordType;

Just a comment here... it's generally a bad idea to use enums for longer-term data 
storage like this, as the size of the enum (i.e. the number of bytes it occupies in 
memory and the subsequent alignment of fields following the enum in the structure) 
varies among compiler implementations. You should really use a byte or integer field 
in the structure instead, with packing pragmas if necessary.

Regards,

Jim Schram
Palm Incorporated
Partner Engineering


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to