On 03-Aug-99 [EMAIL PROTECTED] wrote:

> I'd like to use DmGetNextDatabaseByTypeCreator to collect information about
> all "appl" databases on the Palm.  I have defined a structure to hold the
> card number, local id and name of the databases that are found during the
> search. Being new to Palm programming, I'm not sure the best way to allocate
> memory for the search using the fewest resizes, locks and unlocks.  Having
> no idea how big the result will be means I can't allocate a specific size
> array.  How do people do this?  Can someone suggest a design for this type
> of thing on the Palm?

Much quicker to use SysCreateDataBaseList().  A short example of how to build
the list, iterate through the array, and then free it.

    SysDBListItemType *listP;
    Word AppsPopupCount;
    Handle AppsPopupH;
    short i1;
    ULong curcreator;
    Int curSelection=-1;

    if (!SysCreateDataBaseList(sysFileTApplication, 0, &AppsPopupCount,
        &AppsPopupH, true)) {
        AppsPopupCount = 0;
        AppsPopupH = 0;
    } else {
        /* Figure out the current selection by comparing the creator ID's */
        listP = MemHandleLock((VoidHand) AppsPopupH);
        for (i1=0; i1 < AppsPopupCount; i1++) {
            if (listP[i1].creator == curcreator) {
                curSelection = i1;
                break;
            }
        }
        MemPtrUnlock(listP);
    }

    if (AppsPopupH) MemHandleFree((VoidHand) AppsPopupH);

Take a look at the SysDBListItemType, it has the same information you want:

typedef struct 
        {
        Char                    name[dmDBNameLength];
        ULong                   creator;
        ULong                   type;
        UInt                    version;
        LocalID                 dbID;
        UInt                    cardNo;
        BitmapPtr               iconP;
        } SysDBListItemType;


/* Chris Faherty <[EMAIL PROTECTED]>, finger for PGP */

Reply via email to