Sorry, it was very late at night when I last looked at your code. Try this:

//  if (FldGetTextLength(pCtlField)>0) // wrong test
hText=FldGetTextHandle(pCtlField);
if(hText)
{
    FldSetTextHandle(pCtlField,NULL);
    pText=(CharPtr)MemHandleLock(hText);
    if(*pText)
        addNote(pText,ADD_NOTE_NOTE );//inserts note into database
    MemHandleFree(hText);
}
 FrmGotoForm(PalmLinkPatientNotesForm);


> Did that. No Joy.
>
> I am getting the following in the log as I am debugging:
> CmdGetRemoteRtnName error: ILLEGAL ADDRESS
>
> CmdGetRemoteRtnName error: ILLEGAL ADDRESS
>
> CmdGetRemoteRtnName error: ILLEGAL ADDRESS
>
> CmdGetRemoteRtnName error: ILLEGAL ADDRESS
>
> In Thread Debugger
>
> 10027B74: 584F            addq.w   #4,sp
> 10027B76: 660A            bne.s    *+12                    ; 0x10027b82
>      FrmDispatchEvent(&event);
> 10027B78: 486EFFE8        pea      -24(a6)
> 10027B7C: 4E4F            trap     #15
> 10027B7E: A1A0            dc.w     0xa1a0                  ; Invalid
opcode
> Crash ->10027B80: 584F            addq.w   #4,sp
>
>  } while (event.eType != appStopEvent);
>
> The point where it crashes is very consistant.
>
> I've been beating myself up for three weeks on this bloddy error.  Tried
all
> sorts of things.  Anyone up for a little consulting? (cash)
>
> Thanks,
> Jim
>
> .
> "Philip Sheard" <[EMAIL PROTECTED]> wrote in message
> news:40111@palm-dev-forum...
> >
> > You need to free the handle *instead* of unlocking it. There is no
> automatic
> > garbage collection.
> >
> > > hText is a local variable.  Local to the event handling function of
the
> > edit
> > > form.  The AddNoteDoneButton is the button indicating to save the data
> > > (cancel works fine, it just exits the form)  So I didn't think I would
> > need
> > > to free hText since it should go away once it is out of scope.  I
tried
> > > MemHandleFreeText(hText) just for grins and that got me a memory chunk
> ptr
> > > error. (which seems reasonable)
> > >
> > > If I leave it as it is I keep getting an error writing directly to
> screen
> > > memory.  I don't know how one does that since I am only using the
> > published
> > > API's.  So I suspect some sort of memory stomp perhaps?
> > >
> > > Thanks,
> > > Jim
> > >
> > > .
> > > "Philip Sheard" <[EMAIL PROTECTED]> wrote in message
> > > news:40108@palm-dev-forum...
> > > >
> > > >
> > > > > I think so.
> > > > > Here is the code (snippet)
> > > > > ===============
> > > > > case AddNoteDoneButton:  //Save the data and leave the form
> > > > >  frm = FrmGetActiveForm();
> > > > >  wIDField=FrmGetObjectIndex(frm,AddNoteNoteField);
> > > > >  pCtlField=(FieldPtr) FrmGetObjectPtr(frm,wIDField);
> > > > >  FldCompactText(pCtlField);
> > > > >  textLen=FldGetTextLength(pCtlField);
> > > > >  if (FldGetTextLength(pCtlField)>0) // We can add a note since we
> have
> > > > > something
> > > > >   {
> > > > >   hText=FldGetTextHandle(pCtlField);
> > > > >   FldSetTextHandle(pCtlField,NULL);
> > > > >   pText=(CharPtr)MemHandleLock(hText);
> > > > >   addNote(pText,ADD_NOTE_NOTE );//inserts note into database
> > > > >   MemHandleUnlock(hText);
> > > >
> > > > depending on the provenance of hText, you might need
> > > >      MemHandleFree(hText);
> > > >
> > > > > //  FldFreeMemory( pCtlField );
> > > > >   }
> > > > >  FrmGotoForm(PalmLinkPatientNotesForm);
> > > > >  handled=true;
> > > > >  break;
> > > > > ==================
> > > > >
> > > > > Originally I did not have the line
> > > > > FldSetTextHandle(pCtlField,NULL);
> > > > > and adding the line:
> > > > > FldFreeMemory( pCtlField );
> > > > > would cause it to crash which is why it is commented out.
> > > > >
> > > > > In this example I only have one text field on the whole form.  (so
> it
> > is
> > > > the
> > > > > simplest case)
> > > > > Thanks,
> > > > > Jim
> > > > >
> > > > > --
> > > > > Our new email address is [EMAIL PROTECTED]
> > > > > .
> > > > > "Philip Sheard" <[EMAIL PROTECTED]> wrote in message
> > > > > news:40070@palm-dev-forum...
> > > > > >
> > > > > >
> > > > > > > I have a form where some editing occurs.  When the user
presses
> > the
> > > OK
> > > > > > > button the values are collected off the screen and saved in a
> > > > database.
> > > > > > > Then a gotoForm is called and when this form comes up it
crases
> in
> > > the
> > > > > > forms
> > > > > > > open event.  In that event I have a variety of functions
getting
> > > > called.
> > > > > > If
> > > > > > > I rearrange these functions It will crash in a different
place.
> > > > >
> > > > > > >
> > > > > > > I am using global variables.  Am I over running my stack?  It
> > seems
> > > to
> > > > > me
> > > > > > > that the functions are doing the correct things (because if I
> put
> > > the
> > > > > > order
> > > > > > > of execution differently the program does not crash in the
same
> > > spot).
> > > > > I
> > > > > > am
> > > > > > > a little confused as to how the use of global variables
affects
> my
> > > > stack
> > > > > > > size if any.  Does it?
> > > > > >
> > > > > > The error lies in the form being closed. Have you freed all the
> text
> > > > > > handles?
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > For information on using the Palm Developer Forums, or to
> unsubscribe,
> > > > please see http://www.palmos.com/dev/tech/support/forums/
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > For information on using the Palm Developer Forums, or to unsubscribe,
> > please see http://www.palmos.com/dev/tech/support/forums/
> > >
> >
> >
> >
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>


-- 
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