Another question for everyone.  The following line calls the
SetTextToField function, described below.  Inside this call, it also
calls IntToStr, as you can see.  Now, these 2 functions are in a
different file than the call.
1st.  The call to IntToStr is passed a number, and it sucessfully passes
the resultant string back to file1 and sets pnumstr to the string passed
back.  Now, when SetTextToField is called, the value passed into it is
random!  Why would pnumstr get miss-passed?  Its like its not passing
the value into SetTextToField whatsoever.  The value of pnumstr is,
according to the debugger, correct.  But, when the programs shifts to
the SetTextToField function, the value of ptext that is passed in is
garbage.   Is this an issue of scope?  If so, then why doesnt
MyNum.Number sucessfully get passed into, and back out of IntToStr,
which is in the same file as SetTextToField.  Please help.  thanks!


file1.c
CharPtr    pnumstr;
pnumstr = IntToStr(MyNum.Number);
SetTextToField(ReviewNumField, pnumstr );



file2.c
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;
}

CharPtr IntToStr(Word num)
{

 Char  ptext[7];
 CharPtr  ptemp;

 ptext[0]='\0';
 ptemp = StrIToA(ptext, num);

 return(ptemp);
}




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

Reply via email to