Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!rutgers!njin!princeton!phoenix!bskendig From: bskendig@phoenix.Princeton.EDU (Brian Kendig) Newsgroups: comp.sys.mac.hypercard Subject: Re: Intercepting Command-Dot Message-ID: <10690@phoenix.Princeton.EDU> Date: 4 Oct 89 00:48:03 GMT References: <1071@urbana.mcd.mot.com> Reply-To: bskendig@phoenix.Princeton.EDU (Brian Kendig) Organization: Systems Engineering, NASA Space Station Freedom Project Lines: 69 In article <1071@urbana.mcd.mot.com> willcox@urbana.mcd.mot.com (David A Willcox) writes: >I've stumbled across what seems to be an undocumented feature of >HyperCard: If you type command-period while a HyperTalk script is >running, the script stops. Actually, this is one of those little things that works universally in any Mac program that's worth its snuff. If your Mac is doing something strange or being very slow, hit Command-period. >That's real handy for stopping an errant script, and I suspect that a >lot of you out there already know about it. (Sure wish I had know >about this a month ago when the only way I could think of to get out >of an runaway script was hit the old programmer's button.) The power switch works nicely, too, as does a firm tug on the power cord... >My question: Is it possible to catch the command-dot as an event to >allow the script to do some cleaning up if it gets cancelled? At the >very least, I'd like to get back to the starting card. I'd also like to >let an XCMD clean up its memory. For example, I'd like to be able to do >something like: +++ example nuked +++ >Any suggestions on how to do this? Well, you can't trap the Command-period - it breaks out of any script that is running, so therefore by definition it would automatically break out of any script designed to trap it! Instead, you might do this: onglobal working put true into working ... put empty into working end This makes a global variable, "working", be true if your script is doing its stuff, and empty otherwise. If your script exits properly, working will be reset to empty. However, when no other script is executing, the system repeatedly sends out 'idle' messages. Idle will be called until you enter , and will be called again immediately upon exiting . Idle will never realize that 'working' had been set to true... ... unless you hit Command-Period before returns 'working' to empty. If you hit Command-period in the middle of , will abort, and any handler beginning with 'on idle' will be called. Naturally, the 'idle' handler will realize that 'working' is still true. on idle if (working is true) then cleanUpStuff end idle on cleanUpStuff ... global working put empty into working end cleanUpStuff I hope this points you in the right hyperdirection! << Brian >> -- | Brian S. Kendig | I feel more like I | bskendig | | Computer Engineering | did when I got here | @phoenix.Princeton.EDU | | Princeton University | than I do now. | @PUCC.BITNET | | Systems Engineering, NASA Space Station Freedom / General Electric WP3 |