Klemen Dovrtel wrote:
I would like to create a record and then write some data in it. I don't get an
error during compiling, but during program execution.
error: just wrote to a memory location 0x.... which is storage heap. In oreder
to protect integrity of the user's data, such direct access is not allowed.
How should i write the data to a record then?
code:
typedef struct
{
char time[15];
char temperature[5];
char comment[20];
} DBRecordType;
newRecordH=DmNewRecord(gTempDB,&index,sizeof(newRecord));
newRecordP=(DBRecordType*)MemHandleLock(newRecordH);
StrCopy(newRecordP->time,"test");
DmWrite(newRecordP,0,&newRecord,sizeof(newRecord));
MemHandleUnlock(newRecordH);
DmReleaseRecord(gTempDB,index,true);
You've tried to write data to the storage heap with a StrCopy command
(which is incorrect), and then you followed that command up with a
DmWrite command (which is correct), trying to overwrite the very same
memory location. It looks like what you REALLY wanted to do with the
StrCopy command was to populate the structure, NOT the database record.
Like this...
StrCopy(newRecord->time,"test");
Bob.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/