minow@ranger.enet.dec.com (Martin Minow) (06/26/91)
An application I'm working on uses the PPCToolbox to process remote requests. It is currently running as an application (it will become an INIT/CDEV, or maybe a "faceless background procedure" in the future), and all PPC processing runs in completion routines. (See Keith Rollin's INIT - CDEV demo on the System 7 developer's CD Rom for a similar example.) Since the body of the program runs in completion routines, I need a way to send error status and logging information to the main application. However, when I tried to use PostHighLevelEvent from a completion routine, the function returned error -903 (noPortErr). This is not in the expected error list in Inside Mac VI -- and PostHighLevelEvent is not specifically noted as "can/can't call from completion routines." While I can fall back on using shared globals, I'm wondering if there is any better way for a completion routine to send an "event" to an application. Thanks for any suggestions. Martin Minow minow@ranger.enet.dec.com
smoke@well.sf.ca.us (Nicholas Jackiw) (06/27/91)
In article <23852@shlump.lkg.dec.com> minow@ranger.enet.dec.com (Martin Minow) writes: >However, when >I tried to use PostHighLevelEvent from a completion routine, the function >returned error -903 (noPortErr). How are you specifying PostHighLevelEvent's receiverID? Is it known to be good at the time of posting? >While I can fall back on using shared globals, I'm wondering if there >is any better way for a completion routine to send an "event" to >an application. Hmmm.. the facelessness of your mission shouldn't (per se) cause any problems, unless you're working at the AppleEvent/notifyUser level, in which case you might run into problems. (Speaking of InteractWithUser, has anyone managed to figure out how that works, and if so, would they post an overview? The descriptions of the routines all sound probabilistic: "*If* such action would be in accord with the principle of User Control (never defined), *then* this routine will do X, *otherwise* it might do Y. At any rate, your program shan't regain control.") Back to your situation, Martin: why not post some code? If you do go the shared globals route, you can easily use Gestalt to pass data (or a sysheap data ptr) back and forth between your two jobs. If one of these data is a flag "IncomingMessage," set by the sender when the mutual data is good, polling it in the receiver will build you a special-purpose event manager all of your own. -- --- * --- Nick Jackiw Smoke@well.sf.ca.us | Jackiw@cs.swarthmore.edu Key Curriculum Press, Inc. Applelink:KEY.EDUSOFT | (415) 548-2304 --- * ---
nerm@Apple.COM (Dean Yu) (06/28/91)
In article <23852@shlump.lkg.dec.com> minow@ranger.enet.dec.com (Martin Minow) writes: >Since the body of the program runs in completion routines, I need a way to send >error status and logging information to the main application. However, when >I tried to use PostHighLevelEvent from a completion routine, the function >returned error -903 (noPortErr). This is not in the expected error list in >Inside Mac VI -- and PostHighLevelEvent is not specifically noted as >"can/can't call from completion routines." It sounds like your completion routine is getting called when another process which isn't high level event aware is in control, so you're working with that process' environment which doesn't include a PPC port, so you can't send HLEs. Also, according to my paperweight volume VI, _PostHighLevelEvent may move/ purge memory, so it really shouldn't be called from a completion routine. > >While I can fall back on using shared globals, I'm wondering if there >is any better way for a completion routine to send an "event" to >an application. > Since you're using PPC anyway, you can always use _PPCWrite to send a message back... -- Dean Yu Blue Meanie, Negative Ethnic Role Model, Window Cleaner, etc. Apple Computer, Inc. I've never used the PPC Toolbox in my life...