Xref: utzoo comp.sys.mac.hypercard:4073 comp.sys.mac.programmer:16204 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!usc!apple!radius!lemke From: lemke@radius.com (Steve Lemke) Newsgroups: comp.sys.mac.hypercard,comp.sys.mac.programmer Subject: Re: global variables in code resources Keywords: global variables, code resources, XCMD's, XFCN's Message-ID: <1296@radius.com> Date: 26 Jul 90 01:51:34 GMT References: <12642@june.cs.washington.edu> Followup-To: comp.sys.mac.hypercard Lines: 46 moore@cs.washington.edu (Charles Moore) writes: >I am becoming increasingly frustrated by the prohibition against >global variables in code resources. Is there any way around this? >One possibility for me, since I am writing a HyperCard XFCN is to make >callbacks to HyperCard and use HyperCard globals. I'd like to avoid >this, though, since I assume callbacks to HyperCard will generally be >slow. Also, it seems inelegant since I won't need this information >anymore when my XFCN completes. >Does anybody have any suggestions? Sure. Use THINK Pascal 3.0. I quote from the manual (page 157): Global data in code resources: Code resources cannot have global data. You can take advantage of Pascal's nested procedures to simulate global data. Just nest all of the routines in your program within "main". Thus you would have something like this: unit blah; interface procedure main; implementation procedure main; var global:integer; procedure other; begin end; procedure another; main end; begin end; end. >Charles Moore --Steve -- ----- Steve Lemke, Engineering Quality Assurance, Radius Inc., San Jose ----- ----- Reply to: lemke@radius.com (Note: NEW domain-style address!!) -----