Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: Gestalt - new and improved methods Message-ID: <54051@apple.Apple.COM> Date: 16 Jun 91 21:51:29 GMT References: <1991Jun14.160733.14793@terminator.cc.umich.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 40 In article <1991Jun14.160733.14793@terminator.cc.umich.edu> potts@itl.itd.umich.edu (Paul Potts) writes: >I've been putting together some code to use Gestalt in its new and >improved form. Since it has taken me a while to get it going, I thought >I would post it to save someone else time. > >This uses the new method for checking trap availability described in IM-6, >chapter 3. I've translated some of that code directly into THINK C. > >If anyone finds an error, please post a correction. It seems to work fine. In the code that you posted, you check for the existance of the _Gestalt trap. I don't think this is a good idea. Gestalt is both glue and a trap. When you compile a program with a version of MPW or THINK that supports Gestalt, you end up calling the glue. The glue checks to see if the trap is implemented. If so, the trap is called. If not, the rest of the glue provides some emulated behavior. If you check for the trap yourself, you loose out on this emulated behavior. Actually, the above is just a little shy of the truth. It is possible for you to specify that you want your program to be built for 7.0 or later, in which case you end up calling the trap directly. However, in that case, you can safely assume the existance of _Gestalt and not check for it. By the way, in testAttribute(), why do you use: return (BitTst((void*)&feature, 31 - attribute)); instead of return (feature & (1 << attribute)); ? -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "But where the senses fail us, reason must step in." - Galileo