moore@cs.washington.edu (Charles Moore) (07/26/90)
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? Charles Moore
lemke@radius.com (Steve Lemke) (07/26/90)
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!!) -----
siegel@endor.harvard.edu (Rich Siegel) (07/26/90)
In article <12642@june.cs.washington.edu> 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? Yes. Use THINK C 4.0, which allows you to have code resource with an A4 world, which provides for things like globals and segmentation. R. ~~~~~~~~~~~~~~~ Rich Siegel Staff Software Developer Symantec Corporation, Language Products Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel "I have been known, on occasion, to howl at the moon." ~~~~~~~~~~~~~~~
dan@hayes.fai.alaska.edu (Dan LaSota) (07/28/90)
How much do callbacks to HyperCard from externals slow the execution of an Xternal. I'm not looking for exact measurements just an overall feeling. Along the same lines is it faster to execute HyperTalk commands from within a script of is it faster to make callbacks from the Xternal's code? Thanks Dan LaSota
stadler@Apple.COM (Andy Stadler) (07/28/90)
>How much do callbacks to HyperCard from externals slow the execution >of an Xternal? The callback mechanism itself is very quick and direct. Low overhead. >Along the same lines is it faster to execute HyperTalk >commands from within a script of is it faster to make callbacks >from the Xternal's code? If you are doing something which can be handled through one of the specific function callback (like SetGlobal or GetFieldByXXX or NumToStr) then by all means use the callback - it will be quite efficient. If you are just sending single lines of HyperTalk, through SendCardMessage, SendHCMessage, or EvalExpr, however, the interpreter will actually have to parse, tokenize, interpret, and execute your line. This won't make much difference if you do it a single time; but the interpreter tokenizes scripts and keeps the tokens around, which means that -repeated- execution of a given line will be much faster if it's in a script. --Andy stadler@apple.com