I would guess that you are getting an error on the 

>       rec->data = 10;

call, because you are writing directly to data manager memory, which is
prohibited.  You have the DmSet part right (but I don't think that's really
what you want to do).

What you need to do, is make a MyRecord variable, set its data value to 10,
and then write out to the record.
I added this into your code.  Also, you should use DmWrite, not DmSet.  See
the docs for info on what each one does. One sets a record to some value,
and the other actually writes data from a buffer into the record.

You're really close.  (Pass the address of your MyRecord struct as the third
arg to DmWrite . . . see below.)

Cheers,

DGA

> static void saveRec()
> {
>       DmOpenRef dbRef;
>     
>       dbRef = OpenRecordDatabase(DBNAME, CREATORID,
> DBTYPE);
>       
>       UInt16 at = dmMaxRecordIndex;
>       MemHandle h = DmNewRecord( dbRef, &at, sizeof(
> MyRecord ) );
>       MyRecord *rec = (MyRecord *) MemHandleLock( h );
        MyRecord tempRecord;
>       
        // Don't use the following line
//>     rec->data = 10;
        // Use this instead
        tempRecord.data = 10;
>       
        // Don't use the following line
//>     DmSet( rec, 0, sizeof( *rec ), 0 );
        // Use this instead (assuming you want the record in the DB to have
the data of tempRecord, and not 
        // just a bunc of '0's)
        DmWrite (rec, 0, &tempRecord, sizeof (tempRecord);
>       MemHandleUnlock( h );
>       DmReleaseRecord( dbRef, at, true );
> 
> }

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