Xref: utzoo comp.sys.mac.programmer:5558 comp.sys.mac.hypercard:1813 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!rutgers!att!pegasus!ech From: ech@pegasus.ATT.COM (Edward C Horvath) Newsgroups: comp.sys.mac.programmer,comp.sys.mac.hypercard Subject: Re: XFCN/XCMD string in MPW C v3.0 Message-ID: <2774@pegasus.ATT.COM> Date: 11 Apr 89 19:18:27 GMT References: <1264@internal.Apple.COM> Organization: AT&T ISL Middletown NJ USA Lines: 20 From article <1264@internal.Apple.COM>, by oren@apple.com (Tim Oren): > We've found a way to get the effect of globals. In the same stack where > the XCMD lives, create a dummy resource with known name and type, e.g., > STUB 1. When the XCMD runs the first time, load the resource, detach it, ^^^^^^^^^ > mark it non-purgable and grow it to whatever size you need for your data, > then do any initialization. On following calls, get the resources handle > by name to reacquire your "globals"... NO! do NOT detach! If you do, you will no longer be able to reacquire with Get(Named)Resource: after DetachResource, a call to Get(Named)Resource will get a fresh copy of the original resource, not the detached (and now orphaned!) copy. Also, don't call ChangedResource unless you want changes to your globals retained in the resource. This is almost certainly NOT what you want. I know, you didn't even THINK of calling ChangedResource until I mentioned it... =Ned Horvath=