[comp.sys.mac.programmer] INIT Crashes-- Why?

jas@cadre.dsl.PITTSBURGH.EDU (Jeffrey A. Sullivan) (03/29/88)

I wrote a simple INIT that plays a random snd at startuptime.  However, after
playing the sound, but before displaying the icon (with the showinit resource)
it crashes with an id 10.  Why would it crash?  Is there something that must be
done with INITs after they complete?

here's the code:

pascal int Count1Resources (ResType);
pascal Handle Get1IndResource (ResType, int index);
extern long Time : 0x20C; /* Location of Time in Ticks -- from OSUtil.h */

main()
{

Handle thesnd;
int rand(), numsounds;
ResType rt = 'snd ';

	srand((unsigned int)Time);

	numsounds = Count1Resources('snd ');
	thesnd = Get1IndResource(rt, (rnd(numsounds) + 1)); /* Can't be 0 */
	if(thesnd)
		SndPlay(0L,thesnd,TRUE);
	ReleaseResource(thesnd);

}

...
That's it!  Why would she crash?


-- 
..........................................................................
Jeffrey Sullivan			  | University of Pittsburgh
jas@cadre.dsl.pittsburgh.edu		  | Intelligent Systems Studies Program
jasper@PittVMS.BITNET, jasst3@cisunx.UUCP | Graduate Student