Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.sys.mac.hypercard Subject: Re: Preventing Mouse-Click Actions Message-ID: <40759@bbn.COM> Date: 1 Jun 89 16:00:23 GMT References: <619@ashtate.UUCP> Sender: news@bbn.COM Reply-To: mesard@BBN.COM (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 44 In article <619@ashtate.UUCP> peggyl@ashtate.UUCP (Peggy Lerch) writes: >Is there any way to prevent a button script from executing if >the mouse button is clicked while the script is already executing? Well, the process isn't interrupt driven. That is, it doesn't run the second time until the first invocation is finished. In other words, Hypercard records the second mouse click, but doesn't do anyting with it until the script is done running and Hypercard is looking for something to do. So your question is really: "Is there any way to prevent a script from running if it was run recently?" Here are two approaches: o You could have the script record the time at which it ran in a global variable. Then, at the top of the script, compare this value to the current time, and if the difference is less than N ticks don't run the script again (or beep, or tell the user to take a tranquilizer or something). o At the end of the script(s) set a global variable (e.g. canRun) to true. At the beginning add a conditional like "if canRun = true then exit MouseUp" (or beep and exit or whatever). Then, have an idle handler that sets the variable to false. Thus, the script(s) will only run if there was an idle event between invocations. Notes: o These are untested and off the top of my head. o I like the second approach better. >I'm trying to write educational stacks for my three-year old who >goes click-crazy and then has to wait for a long time for the >script to stop repeating itself. Oh. Forget what I said about the tranquilizers then :-) This could also be useful for Hypercard neophytes who are forever double-clicking, since that's what they're used to from using the Finder. -- unsigned *Wayne_Mesard(); POKE 59468,16 MESARD@BBN.COM BBN, Cambridge, MA