> Hi, I need some help to find Database Name.
> I try to search Database Names by type and save them to an array
> .  I use "DmDatabaseInfo".  However, after program finish, all Items
> in the array always has the same value?  Does anyone know what I did
> wrong.  Here is the part of function I use
>
> for (i=0; i<DmNumDatabases(0); i++) {
>   dbID = DmGetDatabase(0,i);
>
>
DmDatabaseInfo(0,dbID,nameP,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&type,NU
> LL);
>  if (type == MyType) {
>    NameList[index] = nameP;
>    index++;
>  }
> }

its obvious. nameP never changes. you assign each item inside NameList
to nameP - so, all entries point to the same position. when you call
DmDatabaseInfo, it overrides any previously saved item.

you should allocate enough memory for NameList[] to actually store
the database name (ie: 32 chars for each item), and, then *copy*
the data from nameP to the NameList[] array.

>  if (type == MyType) {
>>>> StrCopy(NameList[index], nameP);
>    index++;

but, you should allocate memory appropriately before you do this.

---
Aaron Ardiri                           [EMAIL PROTECTED]
CEO - CTO                                              +46 70 656 1143
Mobile Wizardry                         http://www.mobilewizardry.com/


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

Reply via email to