home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5875 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  1.7 KB

  1. Path: sparky!uunet!decwrl!esl!stimpy!drm
  2. From: drm@stimpy.com (Don McGregor)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Calling Apps
  5. Message-ID: <1349@esl.ESL.COM>
  6. Date: 31 Aug 92 06:09:22 GMT
  7. References: <1992Aug30.172214.16435@pellns.alleg.edu>
  8. Sender: news@esl.ESL.COM
  9. Reply-To: drm@stimpy.com
  10. Organization: ESL, a TRW Subsidiary
  11. Lines: 38
  12. Nntp-Posting-Host: stimpy
  13.  
  14. In article 16435@pellns.alleg.edu, frisinv@alleg.edu () writes:
  15. >
  16. >   For an app I'm working on I need to have ImageViewer called. How do I  
  17. >do this? How do I call any app?
  18.  
  19. Drat.  I just did this a few weeks ago but I don't have the code handy.
  20.  
  21. Anyway, look in the documentation for the Speaker class, which
  22. has a brief example on sending messages to another app.  Basically,
  23. you send a message to the Workspace with the file name.  The 
  24. Workspace then opens the appropriate application and loads the
  25. file.  You want to message the workspace and NOT ImageViewer;
  26. if the user has specified another default application to look at .tiff files, 
  27. that one should be launched instead.  The Workspace manager will look 
  28. up the appropriate app to be used for that file extension.
  29.  
  30. It goes something like
  31.  
  32. int fileOpened, returnCode;
  33. id mySpeaker = [[Speaker alloc] init];
  34. port_t thePort = NXPortFromName(NX_WORKSPACEREQUEST, NULL);
  35.  
  36. if(thePort != PORT_NULL)
  37.   {
  38.     [mySpeaker setSendPort:thePort];
  39.     returnCode = [mySpeaker openFile:"/users/bogon/foo.tiff" ok:&fileOpened];
  40.    
  41.    ...
  42.   }
  43.  
  44. (All code uncompiled and probably guaranteed to crash horribly).
  45.  
  46. All this Mach messaging stuff is so cool, and it's gonna get even cooler.
  47.  
  48. ---
  49. Don McGregor | "That which does not overflow my swap file 
  50. drm@esl.com  | makes me stronger." 
  51.  
  52.