Seems like a simple typo to me.
The first DmWrite:
DmWrite(newRecordPtr,0,&newRecord,sizeof(newRecord));
copies all of newRecord into the database record.
The second DmWrite:
DmWrite(newRecordPtr,0,(CharPtr)
&newRecord->serialnum,sizeof(newRecord));
overwrites the database record with sizeof(newRecord) number of bytes
starting at the address of serialnum within newRecord.
Try eliminating the second DmWrite & see what happens.
Additionally, DmNewRecord marks the newly created record busy.
You need to call DmReleaseRecord to "un-busy-a-fy" it.
Finally, be aware that the DmCreateDatabse call may fail
(and will in extreme low memory conditions), so you
should test its return value before so confidently using
its returned reference to the (possibly not there) database.
-bob mckenzie
-----Original Message-----
From: Aaron Ardiri [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 22, 2001 8:01 AM
To: Palm Developer Forum
Subject: Re: We have read the docs!
you know.. maybe you dont intend to come across the way you do, but
you should take more care in regards to how you "demand" answers for
certain things..
we've all been in your position - AND - we managed to pull through it,
without being a nightmare to others :)
try again - and read the docs AGAIN, if anything maybe find some
sample code in the knowledge base and see if this issue has been
raised before.
// az
[EMAIL PROTECTED]
http://www.ardiri.com/ <--- free games!
> We have read the docs and we have a question on how o save
the text in our field. This is our code.
>
> gDb=DmOpenDatabaseByTypeCreator(yourdbtype,yourapptype,dmModeReadWrite);
>
if(! gDb) DmCreateDatabase(0,yourdbname,yourapptype,yourdbtype,false);
>
DmOpenDatabaseInfo(gDb,&theLocalID,NULL,NULL,&theCardNum,NULL);
>
DmDatabaseInfo(theCardNum,theLocalID,NULL,&theAttributes,
>
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
> theAttributes |= dmHdrAttrBackup;
> theCardNum=0;
>
DmSetDatabaseInfo(theCardNum,theLocalID,NULL,&theAttributes,
>
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
> if (adding)
> {
>
myRecordHandle=DmNewRecord(gDb, &RecordIndex, sizeof(newRecord));
> newRecordPtr=(OurStruct
*)MemHandleLock(myRecordHandle);
> newRecord.cost=Coster;
>
newRecord.serialnum=Serial;
> newRecord.datefield=Dater;
> newRecord.itemname=Namer;
> newRecord.lin=Lin;
> newRecord.nsn=Nsn;
>
DmWrite(newRecordPtr,0,&newRecord,sizeof(newRecord));
>
DmWrite(newRecordPtr,0,(CharPtr) &newRecord->serialnum,sizeof(newRecord));
>
MemHandleUnlock(myRecordHandle);
>
> }
>
> Our code works and actually saves records but in the records, our field's
text is not in there. Please help us! Thanks!
>
>
>
> GOD Bless!!!
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/