the first probelm i am having is everytime the emulator loads, it doesn;t
come to the default opening screen, btu somehow launches into a program i
installed on it. I tried re-downloading the emulator, but the program keeps
loading by default, and i didn't make any switches or prefrences to have it
do that.

the second problem i am having is with data base, when i retrieve records
from a data base the emulator crashes, and i assume there is something wrong
with my memory management, or the DmWrite.

this is how i retrieve text from text field and store them. 
 

textFieldPrt = getObject(frmP,MainFirstNameField);
                        FldCompactText(textFieldPrt);
                        h = FldGetTextHandle(textFieldPrt);
                        s = MemHandleLock((void *)h);
                clientRec.firstName = s;
                        FldSetTextHandle(textFieldPrt, NULL);
                        MemHandleUnlock((void *)h);
                        //MemHandleFree(h);
                                                
                        textFieldPrt = getObject(frmP,MainLastNameField);
                        FldCompactText(textFieldPrt);
                        h = FldGetTextHandle(textFieldPrt);
                        s = MemHandleLock((void *)h);
                        clientRec.lastName = s;
                        FldSetTextHandle(textFieldPrt, NULL);
                        MemHandleUnlock((void *)h);
                        //MemHandleFree(h);
                        
                        textFieldPrt = getObject(frmP,MainPhoneField);
                        FldCompactText(textFieldPrt);
                        h = FldGetTextHandle(textFieldPrt);
                        s = MemHandleLock((void *)h);
                        clientRec.phoneNumber = s ;
                        FldSetTextHandle(textFieldPrt, NULL);
                        MemHandleUnlock((void *)h);
                        //MemHandleFree(h);
                        
                        //Char* FldGetTextPtr (FieldType* fldP) 
        
FrmCustomAlert(DbInputAlert,clientRec.firstName,clientRec.lastName,clientRec
.phoneNumber);
                        
                         //pointer to record
        
                        //create the database record and get a handle to it
                        hrecord = DmNewRecord(contactsDB, &(cursor),
sizeof(clientRec)+6);
        
                        //lock down the record to motify
                        precord = MemHandleLock(hrecord);
        
                        //clear the record
                        //DmSet(precord, 0, sizeof(Client), 0);
        
                        DmWrite(precord,0,&(clientRec),sizeof(clientRec)+6);
        
                        //unlock the record
                        MemHandleUnlock(hrecord);
                        
                        //clear the busy biy and set the dirty bit
                        DmReleaseRecord(contactsDB,cursor, true);
        
                        //incrememnt the totalr ecord count
                        numRecords++;
                        //increment cursor
                        //cursor++;
        
                        isDirty = true;


--------------- 
this next sample is how i retrive my records, the varibale cursor is set
globaly in a different function. is there anything i am missing in memeory
management htta may cause this?

static void setFields(void) 
{ 
        FormPtr form; //contact detail form 
        //CharPtr precord; //A record pointer 
        Int16   index; //The object index 
        Client  *clientRecPtr; 
        
        form = FrmGetActiveForm(); 
        
        //get currect record    
        hrecord = DmQueryRecord(contactsDB, cursor); 
        clientRecPtr = MemHandleLock(hrecord); 
        
        if (clientRecPtr->firstName!= NULL) 
        { 
                //set the text for the first name field 
 
setText(getObject(form,MainFirstNameField),clientRecPtr->firstName);
//precord+ DB_FIRST_NAME_START); 
                //set the text for the last name field 
 
setText(getObject(form,MainLastNameField),clientRecPtr->lastName);//precord+
DB_LAST_NAME_START); 
                //set the text for the phone number field 
                setText(getObject(form,
MainPhoneField),clientRecPtr->phoneNumber);//precord+DB_PHONE_NUMBER_START);

                
        } 
        else 
        { 
                //set the text for the first name field 
                setText(getObject(form,MainFirstNameField)," ");
//precord+ DB_FIRST_NAME_START); 
                //set the text for the last name field 
                setText(getObject(form,MainLastNameField)," ");//precord+
DB_LAST_NAME_START); 
                //set the text for the phone number field 
                setText(getObject(form, MainPhoneField),"
");//precord+DB_PHONE_NUMBER_START); 
        } 
        if(isDirty) 
        { 
                //get the index of our field 
                index = FrmGetObjectIndex(form, MainFirstNameField); 
                
                // set the focus to the first name field 
                FrmSetFocus(form,index); 
                
                //set upper shirt on 
                GrfSetState(false,false,true); 
        } 
        
        MemHandleUnlock(hrecord); 
        return; 
} 


  

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