home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15511 < prev    next >
Encoding:
Text File  |  1992-09-15  |  2.1 KB  |  53 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
  3. From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
  4. Subject: Re: Easiest way to find my PSN (Process Serial Number)
  5. In-Reply-To: ejw1@kimbark.uchicago.edu's message of Tue, 15 Sep 1992 14:46:29 GMT
  6. Message-ID: <D88-JWA.92Sep15204213@dront.nada.kth.se>
  7. Originator: d88-jwa@dront.nada.kth.se
  8. Sender: usenet@kth.se (Usenet)
  9. Nntp-Posting-Host: dront.nada.kth.se
  10. Organization: Royal Institute of Technology, Stockholm, Sweden
  11. References: <1992Sep14.213345.14845@midway.uchicago.edu>
  12.     <x-znmmf.gurgle@netcom.com>
  13.     <1992Sep15.144629.21586@midway.uchicago.edu>
  14. Date: Tue, 15 Sep 1992 19:42:13 GMT
  15. Lines: 36
  16.  
  17. > ejw1@kimbark.uchicago.edu (Eric Weidl) writes:
  18.  
  19.    >>    Is there any easy way to determine my own Process Serial Number?  
  20.  
  21.    >GetCurrentProcess. There are also constants which you can stuff
  22.    >into a PSN, but I can never remember their names, so I just call
  23.    >the trap. :-)
  24.  
  25.    Of course!  If I call GetCurrentProcess right after I am launched, A5 will
  26.    be mine and I'll get my own PSN.  I had been thinking about
  27.    GetCurrentProcess, but figured that I'd call it when I needed it, ie.
  28.    when I was in the background.  At that time, it would return a PSN, but
  29.    not mine.  If I call it before entering my event loop, I'll be in the
  30.    foreground and it should work.
  31.  
  32. A5 is _always_ yours when you're getting time through WaitNextEvent,
  33. so unless you call GetCurrentProcess from interrupt time (or maybe
  34. a trap patch) you should be OK.
  35.  
  36. Note that GetCurrentProcess != GetFrontProcess!
  37.  
  38. Also, if you send AppleEvents to yourself, you should pass the
  39. constant { 0 , kCurrentProcess } for PSN when you create the
  40. destination descriptor. This will give you two benifits:
  41.  
  42. 1) The Apple Event Manager will short-cut the event sending and
  43.    pass it to the event handlers IMMEDIATELY (not wait for you
  44.    to call WaitNextEvent)
  45. 2) Your AppleEvent will be seen by the AppleScript recording
  46.    mechanism.
  47.  
  48.  
  49. -- 
  50. Jon W{tte, h+@nada.kth.se, Sweden, Phone +46-8-107069
  51.  
  52. Help eradicate FIDO-Net <-> Usenet gateways in our time!
  53.