wdh@well.sf.ca.us (Bill Hofmann) (01/01/91)
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. -Bill wdh@well.sf.ca.us D6082@AppleLink.apple.com
Jahnke@brahms.biosci.arizona.edu (Jerome Jahnke) (01/01/91)
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. > How bout making the XCMD an XWindow and allowing HC to send it nullevents? This way you let HyperCard do most of the work and just accept nullevents and test your timer and condition. >-Bill > wdh@well.sf.ca.us > D6082@AppleLink.apple.com > Jer, ---- University of Arizona Dept. Molecular and Cellular Biology jahnke@brahms.biosci.arizona.edu
leonardr@svc.portal.com (Leonard Rosenthol) (01/02/91)
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. > I don't believe you can, Bill. The problem is that Hypercard is not truely reentrant or multitasking, which is really what you want it to be. I see two solutions, one (as suggested elsewhere) is to make your XCMD create an XWindow (they can be invisible) and then do a SetXWIdleTime to get the nullEvents to do the tests you need. This will allow the rest of HC to continue and you can do what you need. If, for some reason, this is not acceptable, you may wish to try using the SendHCEvent and RunHandler callbacks (new with 2.0) which will allow you to pass back individual events (including nulls), and run specific handlers (like 'on idle') respectively. Leonard -- ---------------------------------------------------------------------- + Leonard Rosenthol | Internet: leonardr@sv.portal.com + + Software Ventures | GEnie: MACgician + + MicroPhone II Development Team | AOL: MACgician1 + ----------------------------------------------------------------------
mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) (01/02/91)
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. > I assume general housekeeping (redrawing windows, etc.) is the main function for which you would want Idle time; there seems no workaround for this except to relinquish control from your XCMD and grab it back after the next idle: on doMyThing myXCMD end doMyThing on idle global IAmWorking if IAmWorking then myXCMD end idle myXCMD then propoerly sets the global IAmWorking.
wdh@well.sf.ca.us (Bill Hofmann) (01/04/91)
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
Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (01/07/91)
Jeff E Mandel Md Ms writes in a message to All
JEM> 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.
>
JEM> I assume general housekeeping (redrawing windows, etc.) is the
JEM> main function for which you would want Idle time; there seems
JEM> no workaround for this except to relinquish control from your
JEM> XCMD and grab it back after the next idle:
In HC 2.0, there is a callback(?) described on page 460 of the HyperCard
Script
Language Guide called:
"SendHCEvent(ParamPtr, event);"
This will pass along events recieved from GNE or WNE. As you are (I presume
from the docs) the one in control, you can be scanning for your tickCount
change
in the loop with GNE/WNE and send SendHCEvent while your tickCount hasn't
changed
enough to go head with your XCMD task.
Obviouly this was a common problem in 1.xx
Lawson
--
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org