[comp.sys.mac.programmer] What? No INITs?

stanger@otago.ac.nz (Nigel Stanger) (03/22/91)

In article <1991Mar19.183512.172@otago.ac.nz>, I wrote:
> Hey, does anyone out there have sample source code of an INIT
> that they can send me? I have just started looking at writing an
> INIT, but Inside Mac doesn't seem to help much :-(. I am
> especially interested in something which can sit in the
> background and intercept mouse clicks in the Finder, if anyone
> has done anything like that. All donations will be gratefully
> accepted, however.
> 
> If you can email me a copy of the source, or tell me where I can
> get it via anonymous FTP, that would be great. Thanks in advance.
> 

And guess what? I didn't get a *single* reply! Does no-one out
there have some spare INIT source code that they could send me?
Help!

-- 
See ya
                                Nigel.

/******************************************************************************\
* "If I had a quote, I'd be wearing it."  *  Internet: stanger@otago.ac.nz     *
*       -- Dylan Thomas (I think)         *  SnailMail: Information Science,   *
*                                         *             University of Otago,   *
* "Say no MORE!!!"                        *             P.O. Box 56,           *
*       -- Eric Idle                      *             Dunedin, NEW ZEALAND.  *
\******************************************************************************/

gurgle@well.sf.ca.us (Pete Gontier) (03/24/91)

In article <1991Mar22.161947.192@otago.ac.nz> stanger@otago.ac.nz (Nigel Stanger) writes:
>In article <1991Mar19.183512.172@otago.ac.nz>, I wrote:
>> Hey, does anyone out there have sample source code of an INIT
>> that they can send me? I have just started looking at writing an
>> INIT, but Inside Mac doesn't seem to help much :-(. I am
>> especially interested in something which can sit in the
>> background and intercept mouse clicks in the Finder, if anyone
>> has done anything like that. All donations will be gratefully
>> accepted, however.
>> 
>> If you can email me a copy of the source, or tell me where I can
>> get it via anonymous FTP, that would be great. Thanks in advance.

>And guess what? I didn't get a *single* reply! Does no-one out
>there have some spare INIT source code that they could send me?
>Help!

Your problem is not stinginess in the UseNet INIT writing community. And
not ignorance, either.
 
The problem is that there is no such thing as "an INIT." No one can just
send you "an INIT" and have it be useful to you. Rather than being a documented
programming technique, it is a black art, and there is no One True Way in
which to pursue it.
 
Now, there are several fairly common things you need to know:
 
        1) In order to stay resident, your INIT code segment should
                a) reside in the system heap
                b) be locked
                c) be detached from the resource manager
        2) Never tail-patch a trap unless you know there are extenuating
           circumstances.
        3) Be aware of the many strange ways your development system will
           allow you to access global and/or static storage.
        4) MultiFinder, Microsoft, and HyperCard are your worst enemies.
           Fear them. (There is someone on the net who was on the HC
           development team and will claim HC2 plays by the rules. :-)
	5) Save used registers where appropriate.
	6) Be aware of whether you can move memory.
	7) Remember that, as far the System is concerned, the INIT is the
	   lowest form of scum in the universe. You are not even a control
	   panel device, much less a DA or an app. Greet every inch of
	   progress with divine gratitude. Convince the System you aren't
	   there.
 
I hope this helps. Probably it will help someone in some way. But it is
certainly not a cookbook. It's more like a radiation warning sign.

Now, as far as your desire to intercept Finder clicks goes, probably you
ought to look into the jGNE event filter as described in the Event Manager
chapters of IM. Even though it was documented in volume I, it still works
under System 7. (Others may tell you about patching various event traps,
but jGNE is the only officially sanctioned way of doing things.)
-- 
 Pete Gontier, gurgle@well.sf.ca.us
 Software Imagineer, Kiwi Software, Inc.