Hello everybody!
I'm bit frustrated because my app is giving me problems.... It compiles without any errors.
I have a function to get text from a field and another function to save the text to a database. But when I call the "InsertRecord()" function, the simulator craches (I also try the code in PDA, with same results.. ). I can't guess what's the problem.... can anyone help?
Thanks a lot!
Andr� Augusto



Some functions....

static Err AppStart()
{
   UInt16    attributes;
   UInt32    locks;
   Err        retcode = 0;

// Find the application's data file. If it doesn't exist create it.
if (db = DmOpenDatabaseByTypeCreator(DBType, CreatorID, dmModeReadWrite))
DmOpenDatabaseInfo(db, &dbID, NULL, NULL, &dbCard, NULL);
else
{
if (retcode = DmCreateDatabase(0, DBName, CreatorID, DBType, false))
return retcode;
if (!(db = DmOpenDatabaseByTypeCreator(DBType, CreatorID, dmModeReadWrite)))
return dmErrCantOpen;
// Set the backup bit. This is to aid syncs with non Palm software.
DmOpenDatabaseInfo(db, &dbID, NULL, NULL, &dbCard, NULL);
DmDatabaseInfo(dbCard, dbID, NULL, &attributes, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
attributes |= dmHdrAttrBackup;
DmSetDatabaseInfo(dbCard, dbID, NULL, &attributes, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
nbRec = DmNumRecords(db);
FrmGotoForm(MenuInicialForm);
return retcode;
}


static Boolean InsertFormHandleEvent(EventPtr event)
{
...............................
case ctlSelectEvent:
switch (event->data.ctlSelect.controlID)
{
case InsertOK:
if (GetField(InsertForm, InsertName) != "")
{
InsertRecord();
FrmReturnToForm(0);
}
else FrmCustomAlert(ErrorAlert, "Please complete form", "Enter name", "");
handled = true;
break;
..........................
}


static void InsertRecord()
{
   UInt16        index;
   MemHandle     recH;
   MemPtr        recP;

   // Add a new record at the end of the database.
   index = DmNumRecords(db);
   if (!(recH = DmNewRecord(db, &index, sizeof(DBRecordType))))
   {
       FrmCustomAlert(ErrorAlert, "Unable to create record", "", "");
       return;
   }

StrCopy(dbRecord.name, GetField(InsertForm, InsertName));
dbRecord.quantity = StrAToI(GetField(InsertForm, InsertQuantity));
recP = MemHandleLock(recH);
DmWrite(recP, 0, &dbRecord, sizeof(DBRecordType));
MemPtrUnlock(recP);


DmReleaseRecord(db, index, true);
curRec = index;
nbRec++;
}



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

Reply via email to