Hi all!!
I try to create a database. I have studied the example "contacts" in
falch.net but I cant seem to get it to work. When I try to add to the
database I get the following error:
CTR(unknown version) just read from memory location 0x00000000,
which is in low memory.
"Low memory" is defined as the first 256 bytes of memory. It should not be
directly accessed by applications under any circumstances.
If I try to continue I also get the error: error creating new rec
Do any of you have a clue what I have done wrong?
Thanks in advance!!!
/ Maria
Here is my function saveState:
Err saveState(char * id, char * name)
{
//make a dataBase object:
DataBases dbObj=DataBases("RSRC");
//fecth the pointer to the database:
dbPtr = dbObj.getDbPtr();
// Make sure name and number are not NULL:
if(id=NULL)
id = "";
if(name=NULL)
name = "";
// Make sure the database is open:
Err err;
err = dbObj.OpenDatabas();
if(err)
return err;
else
{
// Pass dmMaxRecordIndex to DmNewRecord to add the record
// to the end of the database:
UInt16 index = dmMaxRecordIndex;
// Calculate the lengh of the new record; remember two bytes for
// null-terminating the strings:
UInt32 NameLen = StrLen(name);
UInt32 IdLen = StrLen(id);
UInt32 size = NameLen+IdLen+2;
// Create the new record:
MemHandle h = DmNewRecord(dbPtr, &index, size);
// Make sure we got a good memory handle:
if(!h)
return 1;
else
{
// Lock the handle, so we can write to it:
void *ptr = MemHandleLock(h);
// We must use DmWrite to write to the records, because
//it's in a
write-protected memory area.
// Remember the terminating nulls for the strings.
// First write the name:
DmWrite(ptr, 0, (const void *) name, NameLen+1);
// Then write the id:
DmWrite(ptr, NameLen+1, (const void *) id,IdLen+1);
// Remember to unlock the handle now that we're done with it:
MemHandleUnlock(h);
// Release the record and mark it as dirty:
DmReleaseRecord(dbPtr, index, true);
}
}
// Everything went smoothly:
return 0;
}
_________________________________________________________________
H�mta MSN Explorer kostnadsfritt p� http://explorer.msn.se
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/