Can someone explain why this fails to work after the first iteration??? I should be
able to reuse and reasign these pointers? The first set will run (altough there is
some strange data in the debugger(see jpg)), but
after that they crash.
Here is a snapshot of the debugger... http://www.jlbecker.com/codewarrior.jpg
Thanks for any help.
CharPtr ptemp = "";
CharPtr ptext = "";
ptext = StrIToA(ptemp, MyArmy.NumArcher);
SetTextToField(ReviewArmyArcherField, ptext);
ptext = StrIToA(ptemp, MyArmy.NumLtFoot); <--- crashes here with a (&#@ error
(serious, looks like gibberish)
SetTextToField(ReviewArmyLtFootField, ptext );
here is the function SetTextToField for reference
void SetTextToField( Word fieldID, CharPtr ptext )
{
FormPtr pform;
FieldPtr pfield;
VoidHand hfield;
CharPtr pfieldtext;
pform = FrmGetActiveForm();
pfield = FrmGetObjectPtr(pform, FrmGetObjectIndex(pform, fieldID));
hfield = FldGetTextHandle(pfield);
if(hfield != NULL)
{
MemHandleResize(hfield, StrLen(ptext)+1);
}
else
hfield = MemHandleNew(StrLen(ptext)+1);
pfieldtext = MemHandleLock(hfield);
StrCopy(pfieldtext, ptext);
MemHandleUnlock(hfield);
FldSetTextHandle(pfield, hfield);
FldDrawField(pfield);
return;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/