Hi All,
   I'm trying to display data from the second field of database, and display it on a 
dynamic list. Hope someone understands what I'm talking about. 
I've simply unpack each record and display on a text field and it was successful. 
However, under some circumstances, I've to use dynamic list to display the data. 

This is what I've been trying to do:

typedef struct {
        Int32 ID;
        const Char *Name;
        const Char *Class;
        const Char *Gender;
} StudentRecord;        

typedef struct {
        Int32 ID;
        char Name[1];
} PackedStudentRecord;

// Unpack Function
static void Unpack(StudentRecord *studentrecord, const PackedStudentRecord *psr)       
 
{
        const char* p = psr->Name;
        
        studentrecord->ID = psr->ID;

        studentrecord->Name = p;
        p +=StrLen(p) + 1;
                
        studentrecord->Class = p;
        p +=StrLen(p) + 1;
        
        studentrecord->Gender = p;
        p +=StrLen(p) + 1;      

}

//Name List Function
static void FillListWithName(ListType *lst)
{
MemHandle RecordHa; 
UInt16 NumRecor, indx; 
char *RecordPointr; 
Char **itemlisT;
const int kCardNumber = 0;
const char *kName = "test-DB";
Err             err;  
LocalID dbID;
ListPtr list;
StudentRecord theStudent;
FormPtr form;

dbID = DmFindDatabase(kCardNumber, kName);
        if(!DbID)
                err = DmGetLastErr;     
        else {
                gDatabase= DmOpenDatabase(kCardNumber, dbID, dmModeReadOnly);
                 if(!gDatabase) 
                         err = DmGetLastErr;
                }
                         
NumRecor = DmNumRecords(gDatabase);

itemlisT = (Char **) MemPtrNew(NumRecor * sizeof(Char *));

for (indx=0; indx < NumRecor; indx++)
{       
        RecordHa = DmQueryRecord(gDatabase, indx);
        
        Unpack(&theStudent, (PackedStudentRecord *) MemHandleLock(RecordHa));
        
        list = (ListPtr) GetObjectFromForm(form, MainStudentsNameList);
        
        RecordPointr = MemHandleLock(RecordHa);
        MemHandleUnlock(RecordHa);
        
  // assuming RecordPointer has a null terminated string,
  itemlisT[indx] = (char *) MemPtrNew(MemPtrSize(RecordPointr));
  MemMove(itemlisT[indx], RecordPointr, MemPtrSize(RecordPointr)); 
 
}

LstSetListChoices(lst, itemlisT, NumRecor);

DmCloseDatabase(gDatabase);
}

void *GetObjectFromForm(FormPtr frmP, UInt16 objectID)
{
  return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID));
}
 
I'm sure that I'm missing something in the Name List Function which I don't know. When 
I debug on POSE, my dynamic list shows a blank screen, although I'm still able to 
scroll up and down. All I just want is to display the Names of each student on the 
dynamic list. 
Am I doing the correct way?? What did I did wrong?? I'm using CW7, hope someone can 
explain to me please.

Sorry for the long post.

Many Thanks
Regards 
Lauren






____________________________________________________________
Watch a championship game with Elway or McGwire.
Enter Now at http://champions.lycos.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