Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!hubcap!mikeoro
From: mikeoro@hubcap.clemson.edu (Michael K O'Rourke)
Newsgroups: comp.sys.mac.programmer
Subject: Inits and Dialogs
Message-ID: <6632@hubcap.clemson.edu>
Date: 29 Sep 89 03:20:13 GMT
Organization: Clemson University, Clemson, SC
Lines: 65

I am trying to get a dialog to display in an init and having loads of
troubles.  My init loads a driver i wrote and i want a dialog displayed
in case of an error when tring to load the driver.

Is there something special that has to be done?  Can someone take a look at
the code below and offer suggestions (possibly as to my stupidity) or could
someone send me example code?

The following init dies when it hits the DisposDialog.  Macsbug says it
dies in the PaintOne routine, if that helps at all.  

Michael O'Rourke
Clemson Unversity

***************************************************************

#include "Color.h"
#include "Appletalk.h"
#include "nAppletalk.h"
#include "SetUpA4.h"

main()
{
int installed;
int refNum;
	RememberA0();
	SetUpA4();
		
	InitGraf(&thePort);
	InitFonts();
	InitWindows();
	InitMenus();
   	TEInit(); 
 	InitDialogs(0L);

	installed = OpenDriver("\p.LABtools",&refNum);
	installed = -98;
	
	if (installed != 0) {
	  switch (installed) {
	   case -1  :
	   case -98 :	
		Error("\pLABtools needs AppleTalk to run."); 
		break;
	   case -2 :
		Error("\pNot enough memory");
	  }
	RestoreA4();
}


Error(s)
Str255 s;
{
#define ErrorID 0
DialogPtr Dptr;
int itemhit;

	ParamText(s,"\p","\p","\p");
	Dptr = GetNewDialog(ErrorID,0L,(Ptr) -1);
	itemhit = 0;
	while (itemhit != 1)
		ModalDialog(0L,&itemhit);
	DisposDialog(Dptr);
}