Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!rpi!bu.edu!snorkelwacker!husc6!unix!mxmora From: mxmora@unix.SRI.COM (Matt Mora) Newsgroups: comp.sys.mac.hypercard Subject: Re: global variables in code resources Keywords: global variables, code resources, XCMD's, XFCN's Message-ID: <14567@unix.SRI.COM> Date: 26 Jul 90 23:50:42 GMT References: <12642@june.cs.washington.edu> <1296@radius.com> <6287@helios.ee.lbl.gov> Reply-To: mxmora@unix.UUCP (Matt Mora) Organization: SRI International, Menlo Park, CA Lines: 76 In article <6287@helios.ee.lbl.gov> beard@ux5.lbl.gov (Patrick C Beard) writes: >In article <1296@radius.com> lemke@radius.com (Steve Lemke) writes: ># >#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. >#--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 I sure would like to see how you solved that problem. >globals solve problems in the most elegant way. >Use THINK C! >- Patrick Beard, Macintosh Programmer (beard@lbl.gov) - Also, you can't have call backs using the nested procedure method. For example, in a code resource I'm writing, I need to pass a procptr to the teclickloop but I can't do that if the procedure is nested. The procedure needs to be at the same level as MAIN. One way to get around that is to stuff a handle into the window's refcon and use that handle as your pseudo globals. Of course this method only works if you have a window to stuff the handle in. This won't work if it is not your window because someone else might be using the wrefcon field. Globals sure would make my life easier! If anybody knows a way to get around this problem let me know. P.s. sorry about all the extra lines but Pnews would barf without them :-) -- ___________________________________________________________ Matthew Mora | my Mac Matt_Mora@sri.com SRI International | my unix mxmora@unix.sri.com ___________________________________________________________