Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!apple!applelink.apple.com!MAC.ROMOS From: MAC.ROMOS@applelink.apple.com (Ian Hendry) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C Includes (was "APDA on a disk") Message-ID: <2052@internal.Apple.COM> Date: 24 May 89 17:15:23 GMT References: <1575@cmx.npac.syr.edu> Sender: usenet@Apple.COM Organization: Yeah, I'm organized. Lines: 93 In article <1575@cmx.npac.syr.edu> pcossenb@rodan.acs.syr.edu (Paul C. Ossenbruggen) writes: > When LSC opens the resource file that has the same name as your project with > the .rsrc extension it does not check to see if that resource file is already > open from another application. This is a major problem when you are using > ResEdit and LSC together in a Multifinder environment because, depending on > is going on at the time, the machine may hang badly if you accidentally forget > to close the resource file in ResEdit and try to run your program. If APPL_CREATOR is defined to be your signature type (appl CREATOR) which is present anyway, Try adding the following ugly hack to your InitMac function after you initialize the managers: if (0 == (h=GetResource(APPL_CREATOR,0)))/* check to see if I can get at my resources */ { SysBeep(1);SysBeep(1);ExitToShell(); } else ReleaseResource(h); If your resource file is open in another app(ResEdit), the GetResource will fail and you will exit with some beeps to let you know what happened. > There needs to be a better way to handle multiple small code resources. I had > this project once that needed lots of little code resources to be loaded in > while the program was running. One thing you might try is a trick from ??MacTutor?? where you load the resource at the start of your program and patch it so that calls made to the resource get sent to your application instead...namely the same source code included in your app. Eats memory, but it also buys you the use of the source level debugger with your CODE resources. An example of the resource patching is as follows: { ProcPtrproc; Ptrpointer; proc = (ProcPtr )__Xmain; h = GetResource('LDEF',129); HNoPurge(h); pointer = (Ptr )StripAddress((Ptr )*h); asm { Move.lpointer,A0 Move.w#0x4EF9,(A0)+; JMP$Absolute Move.lproc,(A0) }; } I include the source code for the LDEF 129 in my application project and put a #define main __Xmain at the top of the LDEF's source code. Make sure that the segment containing the LDEF source does not get unlocked or purged or the pointer will be invalid. Obviously you could make this a function if you had a lot of resources that you were developing. When you are done with development, just recompile the code resource without the "#define main __Xmain", remove the patch code, and copy the resource into your App resource file. Along the same line I would like to see an option for a NON-DESTRUCTIVE BUILD. That is a build that does not erase the file that you are building, only the resources you are replacing. If you are developing a CDEV/INIT both the CDEV and the INIT are separate projects and you cannot build them both into one file (say in your system folder for convenience). Building the CDEV deletes the destination file and any resources in it including the INIT and vis versa. It would be nice if I could specify that I would like these project to only replace: (1) resources that I was building and (2) resources in the .rsrc file. It would save a lot of needless ResEdit work. Ian Hendry MAC.ROMOS@applelink.apple.com Make sure my name is in the subject of any Email, or post replies to network. TE: 408-974-4737 Disclaimer: It was all HIS idea anyway! Nothing I say reflects anything my employer means... or anything I mean for that matter.