Try this:

Sean Rogers wrote:
> 
>>> And here's my loading code:
>>>
>>> FieldPtr fld;
>>> FormPtr frm;
>>> Int itemIndex;
>>> CharPtr newTrackName = 0;
>>> VoidHand h;
>>> UInt index = 0;
>>>
>>> frm = FrmGetActiveForm();
>>> itemIndex = FrmGetObjectIndex(frm, ShowTrackNameField);
>>> fld = FrmGetObjectPtr(frm, itemIndex);
>>> // get the handle to the record
>>> h = DmQueryRecord(VictoryDB, index);
>>> if (h) {
>>> DBRecordType * p = (DBRecordType *) MemHandleLock(h);

newTrackName = MemPtrNew(StrLen(p->TrackName) + 1);

>>> StrCopy(newTrackName, p->TrackName);
>>
>>
>> You have to allocate the pointer before copying something in it.
>>
> 
> I'm not sure how I'd do this. I thought I already had...
> 
>>> MemPtrUnlock(p);
>>> }
>>> FldSetTextPtr(fld, newTrackName);
>>> FldDrawField(fld);
>>>
>>
>> If you use the FldSetTextPtr function, don't forgot to set the 
>> >EditField as non-editable.
>> Don't forgot to release the newTrackName pointer after to avoid memory 
>> leaks.
>>
> 
> How does one release a pointer? I think this may be what's messing me up.

MemPtrFree(newTrackName);

But only when you leave the form.

Ludovic


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to