Take StrLen(pTemp)+1 for the NULL character terminator of C string.
for example,
memoRec = DmNewRecord(MemoPadDB, &index, StrLen(pTemp)+1);
Hope it helps
-AS
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Haagensen, Brandt
Sent: Wednesday, April 19, 2000 10:42 AM
To: Palm Developer Forum
Cc: Haagensen, Brandt
Subject: Writing records to MemoPad
Here is my problem:
It writes the text to MemoPad. When I open MemoPad and view the entry/data
I added, there is a random amount of junk added to the end of my string.
Here is a snippet of my code:
Ptr pRec;
VoidHand memoRec;
Err error;
UInt mode;
CharPtr pTemp = (char*)MemPtrNew(64);
StrCopy(pTemp, "Test One Two Three");
mode = dmModeReadWrite;
MemoPadDB = DmOpenDatabaseByTypeCreator(memoPadDBType,
sysFileCMemo, mode); // memoPadDBType is 'DATA'
// Create a new first record in the database
memoRec = DmNewRecord(MemoPadDB, &index, StrLen(pTemp));
// Lock down the block containing the new record.
pRec = (char*)MemHandleLock(memoRec);
error = DmWrite(pRec, 0, pTemp, StrLen(pTemp));
// Unlock the block of the new record.
error = MemPtrUnlock(pRec);
error = DmReleaseRecord (MemoPadDB, 0, true);
error = MemPtrFree(pTemp);
// Close the application's database.
DmCloseDatabase(MemoPadDB);
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html