[comp.sys.mac] Yet more INIT questions

palarson@watdragon.waterloo.edu (Paul Larson) (10/31/87)

I have two questions.

1. What should not be done by an INIT?   Are there any managers or drivers which are not initialized at the time of INIT execution?  Is there anything which is absolutely verboten?

2. How doest one go about installing a background task with an INIT 
(as per JClock (a clock in the menu-bar))?  Any suggestions would be 
appreciated; source would be manna from heaven (Pascal preferred, but under 
duress, I'll read anything.)

Thanx in advance,
	Johan Larson

jww@sdcsvax.UCSD.EDU (Joel West) (11/02/87)

Counting on having a QuickDraw grafport initialized in an INIT
is a very bad move.  So anything referenced via A5, including
variables such as white, randSeed, etc. is out.

I think QuickDraw can be used in an INIT; I just think you have to
make your own port (I haven't done it, so don't quote me).
Usually INIT's are very simple, like to install some code that
will be used later.
-- 
	Joel West (c/o UCSD)
	Palomar Software, Inc., P.O. Box 2635, Vista, CA  92083
	Author, Programming with Macintosh Programmer's Workshop (Bantam)
	{ucbvax,ihnp4}!sdcsvax!jww 	jww@sdcsvax.ucsd.edu

dmw3@ur-tut.UUCP (David M Walsh Jr.) (11/03/87)

In article <3988@watdragon.waterloo.edu> palarson@watdragon.waterloo.edu (Paul Larson) writes:
>I have two questions.
>
>1. What should not be done by an INIT?   Are there any managers or drivers which are not initialized at the time of INIT execution?  Is there anything which is absolutely verboten?
>
>2. How doest one go about installing a background task with an INIT 
>(as per JClock (a clock in the menu-bar))?  Any suggestions would be 
>appreciated; source would be manna from heaven (Pascal preferred, but under 
>duress, I'll read anything.)
>
>Thanx in advance,
>	Johan Larson

I too am interested in these arcane resources.  If someone could post a simple
INIT to the net that installs a little routine that needs some time from the
system from time to time I would be in heaven.

My other question about INITs is how do they handle variables from say a
Pascal routine??  I'd love to be able to keep some data around, but I have
no ideas on how to go about this.

If anyone cares, I'm writing (trying at least) it in LightSpeed Pascal 1.0 and
I can generate the code resources easily enough, but it's making the program
keep itself in memory and keeping the variables intact that are the major
stumbling blocks here.

Any info will be greatly appreciated,

  Dave Walsh - still trying to be a Mac hacker...

blm@cxsea.UUCP (Brian Matthews) (11/04/87)

In article <4236@sdcsvax.UCSD.EDU> jww@sdcsvax.UCSD.EDU (Joel West) writes:
|Counting on having a QuickDraw grafport initialized in an INIT
|is a very bad move.  So anything referenced via A5, including
|variables such as white, randSeed, etc. is out.

Agreed.  It would only be a bad move if it didn't work.  It's a VERY bad move
because it works under some Systems on some machines, and not on others, so
it's easy to be fooled into thinking it works everywhere.  It DOESN'T.  It's
also fairly simple to initialize Quickdraw's globals and open a port.

|I think QuickDraw can be used in an INIT; I just think you have to
|make your own port (I haven't done it, so don't quote me).

I have used QuickDraw from an INIT.  You have to do a little more than open a
port (QuickDraw generally isn't even initialized at this point), but it's
fairly easy to get things to work.

|Usually INIT's are very simple, like to install some code that
|will be used later.

This is true in general.  The reason I used QuickDraw in the INIT was so I
could set up some structures and calculate some sizes in code that was going
away after it was done (the INIT), thus reducing the amount of code laying in
the system heap all the time.
-- 
Brian L. Matthews                               "A man with one watch knows
...{mnetor,uw-beaver!ssc-vax}!cxsea!blm          what time it is; a man with
+1 206 251 6811                                  two watches isn't so sure."
Computer X Inc. - a division of Motorola New Enterprises