[comp.sys.mac.programmer] Calling InitGraf from a DA in TML Pascal

hirayama@suvax1.UUCP (Pat Hirayama) (08/14/88)

Hello world!

I am a beginning Mac programmer and am writing a DA for my first project.
I am running into a problem that is probably rather trivial for most of
you out there, so I'd appreciate a hint.  

In the Open procedure, I need to make the following calls:

	InitGraf(@thePort)
	InitFonts;
	TEInit;

(That is, I need to use some TextEdit routines, so I need TEInit, which
in turn needs the other two calls; at least, that is what I think I am
reading).  Besides, I will need to use QuickDraw later on, so it seems
best to initialize it at the beginning.

The problem I am running into is that thePort is a QD Global variable
and global variables are not allowed in a DA (or so everyone tells me).  

It is obvious that there is a way around this -- there are many DA's
out there using QD.   Can someone please show me the way?

Thanks in advance,

 
------------------------------------------------------------------------------
 Pat Hirayama, Computer & Information Services, Seattle U, Seattle, WA 98122  

	 UUCP:  ..!uw-entropy!{dataio,thebes}!suvax1!hirayama
	   or:  suvax1!hirayama@entropy.ms.washington.edu

 Bove's Theorem:  The remaining work to finish in order to reach your goal
	increases as the deadline approaches.
------------------------------------------------------------------------------

shane@chianti.cc.umich.edu (Shane Looker) (08/15/88)

In article <1189@suvax1.UUCP> hirayama@suvax1.UUCP (Pat Hirayama) writes:
!In the Open procedure, I need to make the following calls:
!
!	InitGraf(@thePort)
!	InitFonts;
!	TEInit;
!
!(That is, I need to use some TextEdit routines, so I need TEInit, which
!in turn needs the other two calls; at least, that is what I think I am
!reading).  Besides, I will need to use QuickDraw later on, so it seems
!best to initialize it at the beginning.
!
!The problem I am running into is that thePort is a QD Global variable
!and global variables are not allowed in a DA (or so everyone tells me).  

DON'T CALL THE Init calls from a DA!!  If an application is to support 
DAs, there are quite explicit rules as to what it must do.  All Mac
programs which can support DAs have already caled InitGraf.  I guarantee
that.  The should have also Inited everything you will need.  See the Desk
Manager stuff for that.

So the moral is to not call InitGraf & friends from a DA.


Shane Looker
Looker@um.cc.umich.edu