Got my code to work.  Had to update field by redrawing it.

I would still like any insight that anyone might provide into how to create
custom error codes.

One additional area - converting either Int or Double to String (a char as
opposed to an AnsiString...not that I am).

Thanks.
----- Original Message ----- 
From: "Del Ventruella" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[email protected]>
Sent: Saturday, October 29, 2005 8:10 PM
Subject: Re: Getting Text from a Field


> I tried it, but it didn't work.  The compiler doesn't like:
>
> fldP = GetObjectPtr(objectID);
>
>
> ----- Original Message ----- 
> From: "Jeff Summers" <[EMAIL PROTECTED]>
> To: "Palm Developer Forum" <[email protected]>
> Sent: Saturday, October 29, 2005 6:18 PM
> Subject: Re: Getting Text from a Field
>
>
> Looks like the hard way to me.  Try this:
> /**************************************************************
>  *
>  * static Char* GetFldText(UInt16 objectID)
>  *
>  * Get the text from field of name objectID
>  *
>  * ***********************************************************/
>
> Char* GetFldText(UInt16 objectID)
> {
> FieldType* fldP;
> fldP = GetObjectPtr(objectID);
> return FldGetTextPtr(fldP);
> }
>
> You will have to test the string to be sure it is not null, as a blank
> field will give you null.  For example, this is a use of the above
function:
>
> Char BPreTxt[10];
> if ( GetFldText(BPreFld) != NULL ) StrCopy(BPreTxt,GetFldText(BPreFld));
>
> BPreFld is the name of a field on the current form.
> hth,
> /js
>
>
>
> In your message regarding Getting Text from a Field dated Sat, 29 Oct 2005
> 15:38:17 -0000, Del Ventruella said that ...
>
> >  The following was written to get text from a field.  Unfortunately, if
> more
> than four characters are entered in the field, only the first four
> characters
> are returned.  I probably need to resize the handle, but am not certain
how
> to
> go about this.
> >
> >  If anyone can add a hint about how to create a custom error message to
> return and how to use it once it is returned, that would also be very
useful
> for me.  (I suspect the system will handle the error message and
> differentiate
> between system and custom error messages, based upon something I read.)
> >
> >  I'd appreciate any assistance with these two issues.
> >
> >  /*
> >   * FUNCTION: GetFieldTextForStr(FieldPtr field, Char *s, Boolean
redraw)
> >   *
> >   * DESCRIPTION: This routine gets text from a screen object.
> >   *
> >   * PARAMETERS:
> >   *
> >   * frm
> >   *
> >   */
> >
> >  Err GetFieldTextFromStr(FieldPtr field, Char *s)
> >  {
> >  MemHandle h;
> >  Err err;
> >  h = FldGetTextHandle(field);
> >
> >  if (h)
> >  {
> >  StrCopy(s, (Char*) MemHandleLock(h));
> >  //Unlock the string handle.
> >  MemHandleUnlock(h);
> >
> >  FldGetTextHandle(field);
> >
> >  FldDrawField(field);
> >  return errNone;
> >
> >  }
> >  else
> >  {
> >  Err Bad;
> >  return Bad;
> >  }
> >  //At this point, we have have copied the string from the locked handle
> >
> >  //to a char pointer, which is the same char pointer
> >
> >  //that was passed to the routine.  As a result,
> >
> >  //there is no need to return a char.  The change
> >
> >  //has already been made to the data in the memory address
> >
> >  //associated with the char pointer.
> >
> >  }
> >  -- 
> >  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/
>

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

Reply via email to