Ok,

My problem definately lies in the RecordFormInit function.. I think .. Here it is.
once I run this function I am not able to get a Ptr to object on the form.. or maybe
just a Ptr to the form. So from what I know, this function is pretty straightforward
and correct.. but I guess I don't know enough.. b/c it is messing everything up.

static void RecordFormInit (void)
{
  int i;

 //pointer to our data
 MovementRecord *LBufferPtr;
 StaticRecordingInfo *LCurrentStatPtr;
 DynamicRecordingInfo *LCurrentDynPtr;


 /*Initialize the Static recording structure.. we need to wait until this is put in
the DB to get the ID */

 LCurrentStatPtr = MemHandleLock(Stat);
 LCurrentStatPtr->RecordCount = 0;
 MemHandleUnlock(Stat);
 MemPtrFree(LCurrentStatPtr);

 /*Again we initialize what we can..waiting to set up the unique DB ID.*/

 LBufferPtr = MemHandleLock(Buff);
 LBufferPtr->TickCount = 0;
 LBufferPtr->MovementNumber = 0;
 MemHandleUnlock(Buff);
 MemPtrFree(LBufferPtr);

 /*initialize the dynamic data structure, we wait to set the start time until the
recording is
 started.. dam that user! :) */

 LCurrentDynPtr = MemHandleLock(Dyn);
 for (i = 0; i <= 12; i++)
  LCurrentDynPtr->MovementTotals[i] = 0;
 MemHandleUnlock(Dyn);
 MemPtrFree(LCurrentDynPtr);



  //DisableButtons ();
}










"Philip J. Matheson" wrote:

> Hmm, I sent a message allready on this subject but I'm not seeing it. Here it is
> again :
>
> You nailed the problem. When I comment out the RecordFromInit code everything is
>
> dandy. Then when I use to code specified in a prevoius message by Mr. Stricker..
>
> case (frmOpenEvent):
> if(event->data.frmOpen.formID == RecordForm)
> {
>   RecordFormInit();
>   frmP = FrmGetFormPtr(RecordForm);
>   FrmDrawForm(frmP);
>   handled = true;
> }
> break;
>
> I get a curious message about trying to read from unallocated memory.. this is
> when I try to access the button on the form..
> How can make my initialization call *after* the entire form has been built? Is
> there something like case (frmPostOpenEvent)?
> Thank so much to everyone.. Maybe draw the form before I call the init sequence?
>
> Well, now that I see where this error is I realize I was making too many
> assumptions about what the problem was during my debuging.. man I have a lot to
> learn.. : )
>
> Thanks again,
>
> -Philip J.
>
> Dave Lippincott wrote:
>
> > Hmmm...
> > Start looking in RecordFormInit(). I'll bet the problem is only remotely
> > linked to the button or you are doing something to the button or it's
> > resources before the form allocates the form memory.
> > Sometimes stuffing data into memory location that does not have enough
> > allocated will step on other variables.
> > Have you tried removing the offending button, commenting out any related
> > code and see if your app works?  If it does, slowly start re-introducing the
> > button and its code until you find the offending code.  My suggestion (from
> > my experience) is you're looking in the correct general area but not at the
> > specific line that causes the problem.
> > You could also try stepping through your code when this form is being
> > initialized and check the variables involved before and after each line of
> > code.  It may take some time, but you will pinpoint the exact line that
> > causes the error and why.
> >
> > best of luck
> > Dave
> >
> > -----Original Message-----
> > From: Philip J. Matheson <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> > Date: Monday, May 10, 1999 10:11 AM
> > Subject: Re: FormPtr problems STILL! Please Help.
> >
> > >Hi,
> > >
> > >It is a button object. but I have recently commented out the code that gets
> > the
> > >button object and now the program  dies in the forms event loop.
> > >
> > >  case frmOpenEvent:
> > >
> > >       RecordFormInit();
> > >       frmP = FrmGetActiveForm();
> > >       FrmDrawForm ( frmP);   <---------------- Dies right here..
> > >       handled = true;
> > >       break;
> > >
> > >
> > >So this little annoying problem has nothing to do with the control I think.
> > This
> > >for just does not react kindly to be pointed at! I can't seem to get a
> > valid
> > >pointer to it... ugh.
> > >day 3 and I still have no clue where to begin. I could completely recreate
> > this
> > >form.. *but* it has a lot of work in it and I'd rather not.
> > >
> > >Thanks again,
> > >
> > >Philip J.
> > >
> > >
> > >Dave Lippincott wrote:
> > >
> > >> What kind of control are you passing to FrmGetObjectIndex ?  I had a
> > similar
> > >> problem because I was attempting to get the index of an object that did
> > not
> > >> work with this function.
> > >>
> > >> -----Original Message-----
> > >> From: Philip J. Matheson <[EMAIL PROTECTED]>
> > >> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> > >> Date: Sunday, May 09, 1999 2:58 PM
> > >> Subject: FormPtr problems STILL! Please Help.
> > >>
> > >> >Hi,
> > >> >Ok as I said in my previous messages.. One of my forms will not work.
> > This
> > >> >is very frustrating. When I do the API calls mentioned below the program
> > >> >crashes the first time I try to use the variable frmP. That is in
> > >> >FrmGetObjectIndex.. When I step through with the metroworks debugger I
> > end
> > >> >up looking at a bunch of assembly code. When the program finnaly crashes
> > so
> > >> >that I can no longer debug, the function call is (0x4 or 0x8 Unknown)
> > and I
> > >> >can see in the debug window a messages that says "invalid opcode". Now
> > the
> > >> >code that is causing this works for all other forms, just not this form.
> > >> >I've looked at all the values of frmP after the FrmGetActiveForm();
> > call.
> > >> >Everything seems to be OK. and objectID is also correct.  I'm lost here,
> > I
> > >> >don't know where to start. Maybe someone could just give me a little
> > hint
> > >> as
> > >> >to how I could go about attacking this problem? :)
> > >> >
> > >> >I'm thinking there is something in the forms resource definition that is
> > >> >screwy.. but I don't see how, b/c I didn't write that.. :)
> > >> >
> > >> >Thank you,
> > >> >Philip J. Matheson.
> > >> >
> > >> >"Philip J. Matheson" wrote:
> > >> >
> > >> >> When ever I try to use FrmGetActiveForm(); and I'm in a particular
> > >> >> form... it does not work.. I get a bad pointer error.
> > >> >>
> > >> >> This just started happening in code that was working... ugh. I thught
> > I
> > >> >> may have hosed my ROM but I got a new rom for the POSE.
> > >> >>
> > >> >> if I do something like:
> > >> >>
> > >> >> FormPtr frmP = FrmGetActiveForm();
> > >> >>
> > >> >> and then..
> > >> >>
> > >> >> FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)
> > >> >>
> > >> >> the application crashes..
> > >> >>
> > >> >> Now this is only when a particular form is the current form.. other
> > >> >> forms in my application work fine. What could possibly be wrong with
> > the
> > >> >> form? The resource seem to be fine when I look at it in constructor.
> > >> >>
> > >> >> Thanks,
> > >> >>
> > >> >> Philip J. Matheson
> > >> >
> > >> >
> > >> >
> > >
> > >
> > >

Reply via email to