I have a version of this routine running in another program. It gets
called hundreds of times without a problem. I'm trying to get two versions
of it running in my second application (one for numbers and one for strings)
and I've tried about everything including putting my tongue in either cheek
and turning my chair backwords. If I comment out the StrIToA it goes
through the rest of the logic without a problem.
void UpdateFieldTm(int newtime, ULong fieldname){
FieldPtr fld;
FormPtr frmP;
VoidHand oldhand;
CharPtr fldptr;
Int fldIndex;
frmP = FrmGetActiveForm();
fldIndex = FrmGetObjectIndex(frmP, fieldname);
fld = FrmGetObjectPtr(frmP, fldIndex);
oldhand = FldGetTextHandle(fld);
if (!(oldhand)) oldhand = MemHandleNew(11);
fldptr = MemHandleLock(oldhand);
StrIToA(fldptr, newtime);
FldSetTextHandle(fld, oldhand);
FldDrawField(fld);
MemHandleUnlock(oldhand);
}
I've tried a number of versions of this and this one is almost directly
from a sample. The second time my program calls this routine it blows up on
the FldSetTextHandle line. The code below is how I call it.
CurrentSeconds = TimGetSeconds();
TimSecondsToDateTime(CurrentSeconds, &CurrentTime);
UpdateFieldTm((int) CurrentTime.month, MainTodaymmField);
UpdateFieldTm((int) CurrentTime.day, MainTodayddField);
UpdateFieldTm((int) CurrentTime.year, MainTodayyyField);
I still had a problem after I corrected the error Max Bian pointed out.
There must be something I'm missing about handles.
regards,
Dave Mottorn
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/