From: "Milan" <[EMAIL PROTECTED]>

> The sample shows the below 2 structs for creating a Customer table.
> Do I really need those 2 structs to create one table? Can't I just
> use the bottom one and not do the "packing" and "unpacking" they are
> using? What is the purpose of doing it as they did?

The reason they pack the db records is to save space.  Palm OS devices
currently have very limited space, so you should try not to waste any.  The
packed record (below) is used to store one data record in the db something
like this:

00000001John Doe\0123 Street\0SomeCity\0(123)456-7890\0

If you are not going to store a lot of records so you don't mind wasting
space, then you could skip packing and unpacking records and use a structure
like this:

typedef struct {
  SDWord customerID;
  Char name[20];
  Char address[30];
  Char city[20];
  Char phone[22];
} CustomerStruct;

Neil Rhodes explains db packing in his book, "Palm Programming: The
Devloper's Guide" available for previewing online at
http://www.palmos.com/dev/tech/docs/devguide/TableOfContents.htm .

> typedef struct {
> SDWord customerID;
> char  name[1];
> } PackedCustomer;
>
> typedef struct {
> SDWord      customerID;
> const char *name;
> const char *address;
> const char *city;
> const char *phone;
> } Customer;
>



-- 
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