Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!well!wdh From: wdh@well.sf.ca.us (Bill Hofmann) Newsgroups: comp.sys.mac.programmer Subject: Re: Idle and Hypercard 2.0 Message-ID: <22404@well.sf.ca.us> Date: 3 Jan 91 17:11:42 GMT References: <22363@well.sf.ca.us> <5542@rex.cs.tulane.edu> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 33 In article <22363@well.sf.ca.us> wdh@well.sf.ca.us (Bill Hofmann) writes: >Here's a question, since MacDTS is on (gasp!) vacation. I have an XCMD >which sits in a loop waiting for a condition to match or a timer to expire, >but I'd like other processes *in* Hypercard to get time. (That is, GNE or >WNE won't do the trick.) Should I SendCardMessage(paramPtr, 'idle')? That >doesn't seem to work. Suggestions are welcome. Thanks to all those who responded. The biggest thing I learned what that I phrased the question kind of wrong. The purpose of the XCMD is to wait for a condition to match, so it can't return in the meantime. It's kinda like the Toolbox routine Delay()-it's not the *best* way to do it, but it's the easiest for a novice programmer. I solved the problem, like so: do { ...check condition... SendCardMessage(paramPtr, "\pidle"); /* yes, it *does* work */ if (WaitNextEvent(everyEvent, &anEvent, 0, NIL) && anEvent.what == keyDown && AbortKeyTyped(&anEvent)) break; else SendHCEvent(paramPtr, &anEvent) } while (!condition); Since SendHCEvent gets called *every* time, even with nullEvents, the SendCardMessage may be irrelevant, but what the hey. Obviously, as some of you pointed out, Hypercard 2.0 provides a nice feature for sort of multi-tasking, by letting an XCMD create a window and then letting the window receive time as nullEvents. In fact, that's what makes the rest of the product (of which this pesky XCMD is one small part) work. -Bill Hofmann