Andrew,

Using the popup list, you really should just implement your own ListDraw
function.  I have a number of apps that list data from a database and
they all just use their own draw function.  It is simpler than trying to
manage the memory of the char ** for the list data.  At least look at
the docs on how to implement a list draw function, and if you get stuck,
ping the list and I'm sure we'll help.  However, if you really feel you
must use the char **, just make sure you allocate enough memory for each
string in addition to having enough memory for the pointers to the
strings.  In particular, in the code you have listed, you're going to
want to do a StrCopy of the data from the database to the char ** for
the list, so you'll need to have already allocated the memory for it.
Following your current implementation, consider doing this:

char **myName;

myName = MemPtrNew(sizeof(UInt32) * 28);  //because you know there are
going to be 28 items

for (int i = 0; i < 28; i++)
{
        h = DmQueryRecord(MyDB, i);
      myEntry = MemHandleLock(h);
      myName[i] = MemPtrNew(StrLen(myEntry->name));
        StrCopy(myName[i], myEntry->name);
        MemHandleUnlock(h);
}

Be aware that myName has to be around for as long as the list is and
that you are responsible for freeing the memory associated with myName,
both of which are annoying factors for managing the memory associated
with the list.  I would still strongly encourage you to just go ahead
with a list draw function.

DeAnna

-----Original Message-----
From: Andrew Perron [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 21, 2001 10:54 AM
To: Palm Developer Forum
Subject: Re: Dynamic List Content?


I'm open to suggestions...  I'm using it for a popup list, is there a
good way
to make a "popup table"?

Thanks,

Andrew

Stringer wrote:

> >From: Andrew Perron <[EMAIL PROTECTED]>
> >Date: Wed, 20 Jun 2001 22:46:33 -0400
> >Well, here I am with some more list problems/questions.
> > .....
> >Here's the scenario, I have a database on the palm that contains some
> >information like so:
> >
> >    typedef struct {
> >    FlpCompDouble MyFloat1;
> >    FlpCompDouble MyFloat2;
> >    Char* name;
> >    } MyData;
>
> >There are currently 28 entries and I have a list that I created
manually
> >with each of the name entries.  Currently I get access to MyFloat1
and
> >MyFloat2 by using the indexes from the static list contents to
database
> >records.  I would prefer to also get the name from the database and
thus
> >create the list (that way I only have to update the pdb when data
> >changes...)
>
> My recommendation is the 'list' is the wrong UI object to use.
> You can do better what you are trying to do by using the 'table' UI
object.
> That is certainly what I would do!
>
> Roger Stringer
> Marietta Systems, Inc.


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

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