You forgot to write strlen(pTemp) + 1 to write a null byte too.
Otherwise memo (or the field routines) wouldn't know where the data ends.

On Tue, Apr 18, 2000 at 10:12:06PM -0700, Haagensen, Brandt wrote:
> 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

Reply via email to