[comp.sys.mac.programmer] Driver Question

tracyn@dgp.toronto.edu (Tracy Narine) (11/20/90)

Drivers  can have routines which are called periodically.  A desk
accessory is also a driver and can have the same periodic routine.
My question is, does the periodic routine get called  when the desk
accessory is not active or selected from the apple menu?

Related driver question.
I have written a driver and wish to install it into the system folder.    
What kinds of problems might I run into if I use resedit  and 
copy it into the system file and then open it from in my program.
Is there a better way of doing this?

tracy

stevec@Apple.COM (Steve Christensen) (11/20/90)

tracyn@dgp.toronto.edu (Tracy Narine) writes:
>Drivers  can have routines which are called periodically.  A desk
>accessory is also a driver and can have the same periodic routine.
>My question is, does the periodic routine get called  when the desk
>accessory is not active or selected from the apple menu?

The only time the periodic routine is called is when a desk accessory
is open.  If it got put away (by clicking on the goaway box, for example),
then it gets closed and is no longer called.

>Related driver question.
>I have written a driver and wish to install it into the system folder.    
>What kinds of problems might I run into if I use resedit  and 
>copy it into the system file and then open it from in my program.
>Is there a better way of doing this?

If the driver is only going to be used while your application is running,
put it into your application's file.  If it needs to be installed before
the Finder starts up, write an INIT to install it then...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  whoami?     Steve Christensen
  snail:      Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA 95035
  internet:   stevec@apple.com
  AppleLink:  stevec
  CompuServe: 76174,1712

russotto@eng.umd.edu (Matthew T. Russotto) (11/21/90)

In article <1990Nov19.204829.4725@jarvis.csri.toronto.edu> tracyn@dgp.toronto.edu (Tracy Narine) writes:
>Drivers  can have routines which are called periodically.  A desk
>accessory is also a driver and can have the same periodic routine.
>My question is, does the periodic routine get called  when the desk
>accessory is not active or selected from the apple menu?

No, the driver only gets called when open-- i.e. between OpenDeskAcc and
CloseDeskAcc calls.


>Related driver question.
>I have written a driver and wish to install it into the system folder.    
>What kinds of problems might I run into if I use resedit  and 
>copy it into the system file and then open it from in my program.
>Is there a better way of doing this?

I don't understand 'wish to install it into the system folder'.  You can
just copy the driver into your application resource file and open it
from your application--- safer than putting it into the system, anyway.

--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
     .sig under construction, like the rest of this campus.

oster@well.sf.ca.us (David Phillip Oster) (11/24/90)

This is a short summary of how to write drivers.
Get a set of Macintosh tech notes. You can start with just the table of contents
if you have on-line access.

You make a file of type INIT. It contains a resource of type INIT, id=129
is good.  Mark this resource Locked in your development system. In code
it looks like:
main(){
	RenumberDriver();
	OpenDriver();
}
In THINK C, it'll look more like:
#include <SetupA4.h>
main(){
	Handle	drvr;

	RememberA0();
	SetUpA4();
	drvr = GetResource('DRVR', RenumberDriver("\p.MyDriver");
	OpenDriver("\p.MyDriver");
	DetachResource(drvr);
	RetoreA4();
}
You need to write RenumberDriver(). It should search the unit table,
and the current resources, to find an acceptable free slot in the driver
unit table, and renumber the driver so it uses that slot.
Your DRVR resource should have its SystemHeap bit set.
You should also have: a BNDL, an FREF, an ICN# and a signature. The signature
should be registered with apple (Write to them at Apple tech support. They
just want each program to have a unique signature so when a naive user double-
clicks on a document, predicatble thinsg will happen. Your INIT should also
either have the ShowInit resource, or incorporate that code into itself.
I prefer the latter choice, so I can write my INIT to not load itself if
the <Command> key is down, and to draw an X-ed out icon if it fails to load.
If you need a user interface, use a CDEF or RDEV file and add the appropriate
resources to be in the ControlPanel and Chooser respectively. If you need
a lot of memory, add a 'sysz' resource and the system will grow the system
heap before calling your INIT (but you'd better claim your memory at INIT
time, because that space may be used by something else in the system heap later
otherwise.)
See Inside Mac Vol 4 (The Control Panel) for useful additional info.
At INIT time, the stack is in the middle of memory, rather than at the
end, and at one time Apple advised putting things above the stack. No longer,
put them in the system heap.
-- 
-- David Phillip Oster - Note new signature. Old one has gone Bye Bye.
-- oster@well.sf.ca.us = {backbone}!well!oster