[comp.sys.mac.programmer] Questions on INITS

domenikos@emass1.enet.dec.com (George Domenikos) (08/15/90)

Hi there,

I am having an INIT writen in Pascal that crashes whenever is trying to do
anything that calls the OS or the Toolbox such as EventAvail, GetNextEvent,
etc. 
Has anyone run into the same problem before?
Does anyone have a working example of an INIT written in a high level language?
Does anyone know how to specify an INIT to run before or after another INIT?

mxmora@unix.SRI.COM (Matt Mora) (08/15/90)

In article <1850@mountn.dec.com> domenikos@emass1.enet.dec.com (George Domenikos) writes:
>Hi there,
>
>I am having an INIT writen in Pascal that crashes whenever is trying to do
>anything that calls the OS or the Toolbox such as EventAvail, GetNextEvent,
>etc. 

Are you trying to call those routines or trying to patch those routines?
You moust use some inline asm or asm glue to make it work in pascal. You
need to save/restore the registers because pascal will be sure to trash them.

>Has anyone run into the same problem before?
>Does anyone have a working example of an INIT written in a highlevel language?

I have some code that uses the jGNEFilter approach. Its kinda working. I can
make it not crash but then it doesn't do what its supposed to or I can 
make it do its job them it will crash. I guess I still have a few bugs to work
out :-) (but then I could always just put a Microsoft label on it and let it go
at that. :-))      ( Just kidding Microsoft)

What I think I have to do to get it working is to write an asm shell that 
saves the registers calls my pascal code ,gets the return value,restores
the registers and the sets D0 to the value returned.

You can look at the shell of this code in the UMPG on page 241 or there abouts
(the page numbers aren't quite exact yet). The article is called "how to write
an Init in pascal" There is also another article on the subject in chapter 2
page 39. This one patches a trap.


>Does anyone know how to specify an INIT to run before or after another INIT?

Name it so that it is alphabetically before the other one. :-)




-- 
___________________________________________________________
Matthew Mora                |   my Mac  Matt_Mora@sri.com
SRI International           |  my unix  mxmora@unix.sri.com
___________________________________________________________

stevec@Apple.COM (Steve Christensen) (08/15/90)

In article <1850@mountn.dec.com> George Domenikos writes:
>I am having an INIT writen in Pascal that crashes whenever is trying to do
>anything that calls the OS or the Toolbox such as EventAvail, GetNextEvent,
>etc. 

Depending on when and where you call a particular routine, that particular
manager may not be initialized.  For example, you can't create a window if
the window manager is uninitialized.  Maybe something along those lines?

>Has anyone run into the same problem before?

No.

>Does anyone know how to specify an INIT to run before or after another INIT?

The order INITs are run in is determined by the alphabetical ordering of the
file names.  You can't specify that you want to run before or after another
INIT.  It's all random what is run before and after your INIT depending on
what a particular person has installed...

steve

-- 
____________________________________________________________________

  Steve Christensen             Internet:   stevec@goofy.apple.com
  Apple Computer, Inc.          AppleLink:  STEVEC
  20525 Mariani Ave, MS 81-CS   CompuServe: 76174,1712
  Cupertino, CA  95014

  "You just contradicted me."  "No I didn't."
____________________________________________________________________