[comp.sys.mac.programmer] Dialog within an INIT

mcmac@hubcap.clemson.edu (Scott McAlister) (03/22/91)

In an INIT that I am writing, I want to display a Dialog Box when I trap
on MountVol.  I keep getting a "Bus Error" (using 6.0.7 on a IIsi). I am
using THINK C 4.02.

Here is some of my code:
(actually most of this came from J. Peter Hoddie's article in Oct. 89 MacTutor)

showDialog()
{
	DialogPtr myDialog;
	GrafPtr   oldPort;
	int       item;

	GetPort(&oldPort);
	myDialog = GetNewDialog(dialogID,nil,-1);
	SetPort(myDialog);

	do
 	{
		ModalDialog(nil,&item);
	} while (item != 1);

	DisposDialog(myDialog);
	SetPort(oldPort);
}

Any help and/or comments would be appreciated.


-- Scott

==================================================
| Scott McAlister     | mcmac@hubcap.clemson.edu |
| CS Senior           |                          |
| Clemson University  |                          |
| Home address:  390 Boggs Rd.                   |
|                Pickens, SC  29671              |
==================================================

fnahf@rose.uib.no (FLESCHE, HARALD) (04/18/91)

In article <1991Mar21.183154.22245@hubcap.clemson.edu>, mcmac@hubcap.clemson.edu (Scott McAlister) writes...
>In an INIT that I am writing, I want to display a Dialog Box when I trap
>on MountVol.  I keep getting a "Bus Error" (using 6.0.7 on a IIsi). I am
>using THINK C 4.02.


I just wrote an init that displays a dialog upon startup, yes, I know -
one of those "orwellian" inits (see tn 256). It bombed every time I
referenced the dialogPtr returned by NewDialog. After trying *everything*
I remembered reading an article written by the programmer of "initcdev".
He gives the solution: clear the DeskHook global early in your code
(i.e. DeskHook = 0L). If that doesn't work try to allocate more memory,
by increasing the value of your "sysz" resource.

Tor Olaussen
Nansen Remote Sensing Center
University of Bergen
Bergen, Norway