From: "Jonathan King" <[EMAIL PROTECTED]>
> Here is a simple way to do what you are doing.
>
> static void GetFieldData( UInt16 fld, Char *text )
> {
> FormPtr frm = FrmGetActiveForm();
> FieldPtr fldP = FrmGetObjectPtr(frm,
> FrmGetObjectIndex(frm,fld));
>
> if(FldGetTextLegnth(fldP))>
which needs to be:
if(fldP && FldGetTextLegnth(fldP))
if the point about the field itself being null is to be handled,
but since the code already tests the field handle for NULL
the only other thing you're doing is checking for an empty
string which, from memory, StrCopy will handle acceptably
so I'm not sure that this code adds much and...
> {
> StrCopy(text, FldGetTextPtr(fldP);
... you're not testing the FldGetTextPtr() return value for
null and, as far as I'm aware, this can return null so your
code is more fragile than the original druid proposed.
No?
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:bounce-449914-
> > [EMAIL PROTECTED] On Behalf Of druid
> > Sent: Friday, July 22, 2005 8:53 PM
> > To: Palm Developer Forum
> > Subject: Checking to see if field has data in it before passing it
> routine
> >
> > I need to check to see if the field has data in it before I pass it
> to
> > GetFieldData.
> > What is the best way to do that and assign a text value to name
> > if the field is NULL
> >
> >
> > GetFieldData( fldName, name );
> >
> >
> >
> >
> > static void GetFieldData( UInt16 fld, Char *text )
> > {
> > FormPtr frm = FrmGetActiveForm();
> > FieldPtr fldP = FrmGetObjectPtr(frm,
> FrmGetObjectIndex(frm,fld));
> >
> > MemHandle hText = FldGetTextHandle(fldP);
> > if (hText)
> > {
> > MemPtr *pMem = MemHandleLock( hText );
> > StrCopy( text, (Char*)pMem );
> > MemHandleUnlock( hText );
> > }
> > }
> > --
> > For information on using the PalmSource Developer Forums, or to
> > unsubscribe, please see http://www.palmos.com/dev/support/forums/
>
>
>
> --
> For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/