Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!usc!ucsd!helios.ee.lbl.gov!ux5.lbl.gov!beard From: beard@ux5.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.hypercard Subject: Re: global variables in code resources Keywords: global variables, code resources, XCMD's, XFCN's Message-ID: <6287@helios.ee.lbl.gov> Date: 26 Jul 90 19:36:29 GMT References: <12642@june.cs.washington.edu> <1296@radius.com> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux5.lbl.gov (Patrick C Beard) Organization: Berkeley Systems, Inc. Lines: 59 X-Local-Date: 26 Jul 90 12:36:29 PDT In article <1296@radius.com> lemke@radius.com (Steve Lemke) writes: #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 I don't agree. THINK Pascal 3.0's lack of support for global variables is appalling. THINK C 4.0 supports REAL global variables that persist and are accessible across files. The other day I was modifying a code resource written in THINK Pascal, and because I couldn't use REAL globals, I had to add a ton of if statements in awkward places. Sometimes REAL globals solve problems in the most elegant way. Use THINK C! -- ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------