[futurebasic] Re: [FB] More Serious Help

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1998 : Group Archive : Group : All Groups

From: Mark Goodes <wave@...>
Date: Mon, 26 Oct 1998 19:11:14 -0500
>and the jumptable looking like this, in the first segment:
>"myJumpTable"
>ENTERPROC( gCmd%)
> DIM param1%, param2&, param3&, param4%
> SELECT gCmd%
>  CASE _testFunction
>   POP WORD( @param1%) : POP LONG( @param2&)
>   POP LONG( @param3&) : POP WORD( @param4%)
>...
> END SELECT
>EXITPROC
>RETURN
>
>As can be expected - it dropped me squarely in MacsBug on the
>ENTERPROC line.

You should be using a structure like this:
ENTERPROC(param1%,param2&,param3&,param4%,selector%)
SELECT selector%
  case _testFunction
       Fn TestFunction(param1%, param2& , param4%)
END SELECT
EXITPROC

Your code above might have crashed because of the global after the
ENTERPROC command.

>>>
  CLEAR LOCAL MODE
  LOCAL FN doSomething( cmd%, adrPtr&, recPtr&, state&, callBackPtr&)
   DIM result%
   DIM RECORD paramRec
    DIM param1%
    DIM param2&
    DIM param3&
    DIM param4%
   DIM END RECORD .paramRec
   DIM pr.paramRec
   '  now fill in the above record
   ...
   '  now call the callbackPtr&
   CALL callbackPtr&( %_myDoSomethingConstant, @pr)
       ...
  END FN = result%
<<<

This seems like a lot of extra work because you would have to reformat all
your funcitons.  You could try:
CLEAR LOCAL MODE
  LOCAL FN doSomething( cmd%, adrPtr&, recPtr&, state&, callBackPtr&,
param1%, param2&)
   DIM result%
   PUSH WORD (@param1%)
   PUSH LONG (@param2&)
   ' This way you set up the stack before calling the function.
   '  Now call the callbackPtr& using TJ's idea.
   CALL callbackPtr&( %_myDoSomethingConstant)
  END FN = result%
This assumes three things, though:  1.  You know exactly how to set up the
stack for a particular function call.  2.  The FB call statement doesn't do
any more playing with the stack (the ENTERPROC command does do this, by the
way, so you were right about this).  3. You like assembler (because you
will need to step through MacsBug some more to verify assumption #2).

>At the moment, I'm writing code in my notebook in the metro.
I hope your subway isn't as bouncy and crowded as ours is.  :-)



____________
wave (Toronto, Canada)
Last year I was a professional.
This year I'm happy if I can just get through the day.