[comp.sys.mac.programmer] Writing an RDEV under THINK C 4.0

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

In article <3166@moondance.cs.uq.oz.au> tonyg@batserver.cs.uq.oz.au writes:
>I am attempting to write an RDEV to work under Chooser.  The language I
>am using is THINK C 4.0, and I'm having problems getting the chooser to
>display buth the buttons in the dialog.  It also doesn't appear to be
>calling my code at all.

I just did this recently. Success depenmds on careful reading of the Device
Manager chapter of Inside Mac Vol4. You will see that the header that THINK
C generates is not quite right.

here is the complete text of a C program to fix up the header of your
resource:
/* X-10PACKFixer  - Copyright  1990 by David Phillip Oster
	The point of this program is to install the flags long word
	in the header of the PACK of the X-10 gateway

	the hex constant means:
		uses AppleTalk,
		handles the following procedures:
 */
#define bAppleTalk		(1L << 31)
#define bMultiSelect	(1L << 28)
#define bLeftButton		(1L << 27)
#define bRightButton	(1L << 26)
#define bNoSaveZone		(1L << 25)
#define bUseZoneName	(1L << 24)
#define bNewSel			(1L << 16)
#define bFillList		(1L << 15)
#define bGetSel			(1L << 14)
#define bSelect			(1L << 13)
#define bDeselect		(1L << 12)
#define bTerminate		(1L << 11)

main(){
	LongInt		*np;
	Handle		h;
	Integer		res;

	/* This stuff is so Vaccine won't croak
	 */
	InitGraf((Ptr) &thePort);
	InitFonts();
	InitWindows();
	InitCursor();
	InitDialogs(NIL);
	TEInit();

	if(-1 != (res = OpenResFile((StringPtr) "\pYourFileHere"))){
		if(NIL != (h = GetResource('PACK', -4096))){
			np = (LongInt *) (*h + 0xC);
			*np = bAppleTalk | bGetSel | bSelect | bDeselect;
			SetResPurge(TRUE);
			ChangedResource(h);
			SysBeep(1);
		}
		CloseResFile(res);
	}
}
-- 
-- David Phillip Oster - Note new address. Old one has gone Bye Bye.
-- oster@well.sf.ca.us = {backbone}!well!oster

hpoppe@ncar.ucar.edu (Herb Poppe) (04/11/90)

In article <17175@well.sf.ca.us> oster@well.sf.ca.us (David Phillip Oster) 
writes:
> In article <3166@moondance.cs.uq.oz.au> tonyg@batserver.cs.uq.oz.au 
writes:
> >I am attempting to write an RDEV to work under Chooser...
> 
> I just did this recently...
>
> here is the complete text of a C program to fix up the header of your
> resource:
> /* X-10PACKFixer  - Copyright  1990 by David Phillip Oster
>         The point of this program is to install the flags long word
>         in the header of the PACK of the X-10 gateway
                                           ^^^^^^^^^^^^
This looks intriguing. Would this have anything to do with the X10 "home 
control system", where commands can be sent over the 110 VAC house wiring 
to turn appliances, lights, etc. on and off? Would you care to comment on 
what this beast is?

Herb Poppe            NCAR
hpoppe@ncar.ucar.edu  1850 Table Mesa Drive
                      Boulder, CO  80307-3000
                      (303) 497-1296