Tom wrote:
The Palm Database manager, from what I looked at, you can create a
record and tweak it and so on. But if I have an array of the structure
below how would I track this with the Database manager?

typedef struct {
       unsigned int Type;
       unsigned int Position;
       unsigned int *Pin[10];
} Card

Are you sure you really want that "*" there?  Do you want an array of
10 pointers or an array of 10 integers?  It seems like an array of
10 integers would be most appropriate for a card.  By the way, you
don't need a full-sized int for a single digit.  You can just use
a Char.  Even though the name says it's a character, it's just a
one-byte integer, which is plenty big for storing a decimal digit.

typedef struct {
       unsigned int Num;
       unsigned char *name[16];
       Card cards[10];
} CardHolder

Again, do you really want a "*" for the name?  That makes an array of
16 pointers, which implies you want 16 strings.  But I'm thinking what
you may be wanting is an array of 16 characters, i.e. one string.

Anyway, personally I would approach this problem by writing routines
to load an store individual records in the database.  I wouldn't use
the same format in the database that I do in memory.  It's a little
more work up front, but if you write routines to create records and
parse them (converting from and to your in-memory structs), it makes
things cleaner later on, especially if you write into the database
in a platform neutral way.  If you just copy the whole struct, then
you are going to have to deal with all kinds of alignment and
endianness issues, which I think it's best to avoid.

  - Logan

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

Reply via email to