Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple2 Subject: Re: Argh! That blasted StartUpTools()! Message-ID: <42396@apple.Apple.COM> Date: 27 Jun 90 06:26:07 GMT References: <9005291535.AA26340@apple.com> Organization: Apple Computer Inc, Cupertino, CA Lines: 63 This reply is a little late, but Oh Well.... In article <9005291535.AA26340@apple.com> JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") writes: > I am working on a NDA which needs to start up some tools. So > I take the easy way out, I use the Tool Locator's StartUpTools () > function. This is a scary thing. StartUpTools is really intended to be used by applications. For one thing, it's going to do an OpenResourceFile on a pathname that is currently built from prefix 1 and the result of the GS/OS call GET_NAME, which gives the current application name. This means StartUpTools is probably going to open the current app's resource fork a second time, adding it to the resource search path for your NDA's user ID. This won't usually cause any harm, but it will at least prevent the application from closing and reopening its own resource fork for read/write access, which some applications need to do. > [...] > global variable, toolsloaded, is also set so I can tell if I had to > start any tools myself and so my Close function will call > ShutDownTools (). Shutting down tools in your Close function is probably a bad idea. Consider what would happen if I installed TWO copies of your NDA, opened the first, opened the second, and then closed the FIRST. The second copy would still be open, but some of the tools it expects would already be shut down. I usually recommend shutting down tools at DeskShutDown time (your DA's Init routine gets called then, with a flag saying whether it's for StartUp or ShutDown). >[...] > if (!QDAuxStatus ()) > myTools.whichTools[myTools.numTools++].toolNumber = 0x0012; I have *not* looked at the code that gets generated for this in ORCA/C, but I suspect the results of xxxStatus are undefined in the case that the toolset is not loaded. The Status functions are inside the toolsets, so if they aren't there the tool dispatcher returns error 1 or 2, but the function result on the stack is unchanged--you get back whatever the compiler pushed as room-for-result, which is probably garbage (whatever was in A, for example). The following may work, but I'd have to check the resulting code to make sure: if(!QDAuxStatus() || _toolErr) ... > programID = GetNewID (0x5100); > toolref = StartUpTools (programID, 0, (Long) &myTools); It would be better to use your REAL user ID, as returned by MMStartUp. Why? For one thing, it's simpler. For another, by feeding it to StartUpTools you're feeding it to ResourceStartUp, and you're losing the benefit of having the system automatically call SetCurResourceApp for you whenever it calls your NDA's Action & other routines. -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.