I want to read the data from a database and set them in a list in a 
dynamic way, I mean without caring how many fields that database 
has. The code I�m using is:

static void FillList(DmOpenRef Base, ListType *lst)
{
        char **itemList;
        char * recPtr = NULL;
        MemHandle recHandle;
        int probe, numOfRecords;

        numOfRecords = DmNumRecords(Base);
        
        probe = 0;
        itemList = (char **) MemPtrNew(numOfRecords * sizeof(char*));
        gListChoices = itemList;
        gListNumItems = numOfRecords;   
        
        while (numOfRecords > probe){
                
                recHandle = DmGetRecord(Base, probe);
                if (recHandle == NULL) 
                        ErrDisplay ("ERROR");
        
                recPtr    = MemHandleLock(recHandle);
        itemList[probe] = recPtr;
                
              DmReleaseRecord (Base, probe, true);
    
                probe++;
                
            if (recHandle)
                MemHandleUnlock(recHandle);
        }

        LstSetListChoices(lst, itemList, numOfRecords);
}


Code in frmOpenEvent (MainFormHandleEvent):


        list = (ListType *)FrmGetObjectPtr (frmP,
FrmGetObjectIndex(frmP, MainList));
        FillList(UbicDB, list);
        LstSetSelection(lista, 0);


Code in frmCloseEvent (MainFormHandleEvent):


        if (gListChoices) {
                for (i=0; i<gListNumItems; i++){
                        MemPtrFree((MemPtr) gListChoices[i]);
                        MemPtrFree((MemPtr) gListChoices);
                        gListChoices=0;
                }
     }  

When I execute the program only the first field appears and nothing 
more.

PD: When I create the list I put 1 visible item (I can't put more 
because the CodeWarrior Linker says that no fields exist for the 
list, this value can�t be bigger than 1 and my idea is to creat the 
fields at  runtime) so I don�t put any field.

Thanks.

---
Gonzalo Piano.
[EMAIL PROTECTED]

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