Ok. I'll use a handle. Here's the whole function anyway (for the whole Palm
Developer Community to laugh at!...Remember I'm still learning)

static Err WriteFldText(Word FldID, CharPtr newtext)
{
        FieldPtr fld;
        CharPtr disptext=MemPtrNew(16);  //changed from sizeof thing!
        fld=GetObjectPtr(FldID);

        if(fld==NULL)
        {       //checks
                FrmCustomAlert(CustomAlert,"","FldWrite:Not a valid field for this
form","");      //gets Field Pointer
                return (1);
        }
        else


                FrmCustomAlert(CustomAlert,"","Writing Field...","");
                FldSetMaxChars(fld, 16);
                FldSetTextPtr(fld, newtext);
                FrmCustomAlert(CustomAlert,"",newtext,"");
                StrCopy(disptext,newtext);
                FldDrawField(fld);
                FldFreeMemory(fld);
        }
        if (disptext) MemPtrFree(disptext);
        return (0);
}

It definitely was this crashing the program, as I couldn't crash it when I
commented it's calls out. I'll rewrite it and then show you. I may be a
while!

Thanks.

Stuart Norton

-----Original Message-----
From: Aaron Ardiri [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 14, 1999 1:16 PM
To: [EMAIL PROTECTED]
Subject: RE: MemoryMgrNew Crash


On Wed, 14 Jul 1999, Stuart Norton wrote:
> I searched through, and the only reference to 'handle' is the verb sense.
> There are no 'handles' as in nouns anywhere! Also, something is going
wrong
> on exit, and it crashes 50% of the time.

  :>

> I may have found it though. I'm assigning memory for a temporary CharPtr.
> Here's the line:
> CharPtr disptext=MemPtrNew(sizeof(newtext));
> I'm then pointing the field to disptext, copying newtext to disptext using
> StrCopy, and updating the field. I'm hoping this procedure would work for
> writing to the display but it doesn't. Firstly, is using "sizeof(newtext)"
> acutally assigning enough memory, and secondly why doesn't it work? I read
> somewhere that you don't need to use a text handle for read only fields,
but
> can just use FldSetTextPtr() as I am doing.

  if you take a look at the documentation, MemPtrNew says it allocates
  a chunk of NON MOVABLE memory. this term is vague.. but maybe this
  is your problem?

  i had the same problem earlier with this.. and i believe that GUI
  code is possibly "moving" it? (as i said, it is very vague what
  this means)..

  what are you assigning to that pointer? are you moving data from
  a database field into the field? or are you just copying a constant
  string?

> Aaron: Thanks for the code. I'll try it if no-one writes back with a Ptr
> solution.

  i believe the "handle" process is the way to do it in the most
  stable manner.. i could not get the pointer (MemPtrNew) working
  either..

az.
--
Aaron Ardiri
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 352 8192           A/H: +46 26 10 16 11



Reply via email to