[comp.sys.mac] INITs

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

A wild urge to write an INIT recently came over me.  The problem is that I have not been able to find any documentation as to how to go about it.  The LSP 
Release 1.0 Supplement claims that code resources, a set in which INITs are 
included, are documented in Inside Macintosh.  I have not been able to find any referece to them among these hallowed pages.  

Where should I turn?  I need guidance from the ground up.  Please e-mail any 
responses; I'll summarize to comp.sys.mac if necessary.

Thanx in advance,
	Johan Larson

jmunkki@santra.UUCP (Juri Munkki) (10/27/87)

In article <3917@watdragon.waterloo.edu> palarson@watdragon.waterloo.edu (Paul Larson) writes:
>A wild urge to write an INIT recently came over me.  The problem is that I have not been able to find any documentation as to how to go about it.  The LSP 
>Release 1.0 Supplement claims that code resources, a set in which INITs are 
>included, are documented in Inside Macintosh.  I have not been able to find any referece to them among these hallowed pages.  

You really don't need much documentation anyway. Just imagine you're writing
for an ancient computer that has never heard of initializing managers or loading
programs dynamically...

Ok...I'm not an expert in INIT resources, I've only written three of them.
Here's a really short init. It is in Lightspeed C 2.11 and works only on a
Mac II. You should set the file type and make the INIT resource locked. I
also make it preload, but I guess that doesn't mean anything for an init.
It "randomly" plays a 'snd ' resource. You can put the resources in the file,
but it might play one of your beepsounds.

/* StartupSound.c */
#include <MacTypes.h>

void	main()
{
	Handle		foo;
	Ptr		channel;
	unsigned long	time;
	int		theid;
	
	theid=CountResources('snd ');
	GetDateTime(&time);
	
	foo=(Handle)GetIndResource('snd ',time % theid + 1);
	SndPlay(0,foo,0);
}

Juri Munkki
Helsinki University of Technology Computing Centre
jmunkki@santra.hut.fi
jmunkki@fingate.bitnet