> From: Todd Cary
>
> Now my question is how does one store items in a DB *and* then add them
> to the List at run time?  Is there an example in the "Bible"?
>

I haven't read *that* Bible, so I can't say what's in it.  Your question has
2 parts.

a) How to store items in a DB:

On Palm OS devices, a Database is just a storage area where you can store
"records".  Each record consists of whatever bytes you want to store, in
whatever format you want to store them, with a maximum of slightly less than
64KB per record.  You should store the info in a manner that makes sense for
your application, but doesn't waste too much space.  The most likely way to
waste a lot of space is to store fixed-length strings that aren't full of
data.  For example,

// untested code...
typedef struct
{
  Char name[30];
  Char code[20];
} PeopleInfo, *PeopleInfoPtr;

PeopleInfo pi;
PeopleInfoPtr pip;

StrCopy(pi.name, "Joe");
StrCopy(pi.code, "A");
...
// create and write a new record in the open database
UInt16 recordIndex = dmMaxRecordIndex;
MemHandle myRecord = DmNewRecord(db, &recordIndex, sizeof(pi))
pip = (RegistrationInfoPtr) MemHandleLock(myRecord);
err = DmWrite(pip, 0, &pi, sizeof(pi));
MemHandleFree(myRecord);
...

If there are lots of records, you can see that a lot of space is wasted.
Therefore, it is more common to "pack" string data so, for example,
"Joe/0--------------------------A/0------------------" is stored as
"Joe/0A/0".  (/0 here is the terminating NULL.)

</VERBOSE-MODE></* who knows when it started> */>

b) how to add strings to a list at run-time:

Use LstSetListChoices().  David Fedor published a good list example and
description just a few days ago, so check the archives.



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