home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13230 < prev    next >
Encoding:
Text File  |  1992-07-30  |  3.0 KB  |  74 lines

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!mips!swrinde!elroy.jpl.nasa.gov!ames!kronos.arc.nasa.gov!joshr
  2. From: joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: tcl question
  5. Summary: how do I know if a document has been closed?
  6. Keywords: oop, tcl, object oriented, documents
  7. Message-ID: <1992Jul30.222601.8743@kronos.arc.nasa.gov>
  8. Date: 30 Jul 92 22:26:01 GMT
  9. Sender: joshr@kronos.arc.nasa.gov
  10. Followup-To: joshr@kronos.arc.nasa.gov
  11. Distribution: comp.sys.mac.programmer
  12. Organization: NASA/ARC Information Sciences Division
  13. Lines: 58
  14. Nntp-Posting-Host: kronos-arclan.arc.nasa.gov
  15.  
  16. Hey netters, 
  17.  
  18. I have a somewhat tcl specific question here which I'll bet money is
  19. not a FAQ.  On second thought, maybe it is, but here goes.
  20.  
  21. I'm writing an application that shows a table of contents.  The app can be 
  22. launched with appleevents from hypercard.  What I'm trying to do is the 
  23. following:  if the user launches the app with a ceratain table of contents (toc)
  24. and then goes back to hypercard and launches it again, the application
  25. will open the file twice.  What I want is that when the user
  26. launches it the second time, the application would realize that
  27. that file is already being looked at (has a current CDocument associtaed
  28. with it) and not open it again.
  29.  
  30.  
  31. My first guess was to check CDocument's field itsSupervisor, like this
  32.  
  33. itsSupervisor->itsDependents->NthItem(i)->GetClassName(aStr255)
  34.  
  35. then when I knew what CDocuments were dependent on the application, I could
  36. check each's window's name to figure out what file they were associated with.
  37.  
  38. The probelm is, itsDependents turns out to nbe a protected member, so I
  39. can't access it directly through CDocument.
  40.  
  41. Here are some ways of doing this I thought up, and their pitfalls.
  42. Your input is welcome.
  43.  
  44. The most elegant way would be to simply keep track of which files were opened
  45. and closed in a CList assosiated with CTOCDoc, my descendent of CDocument.
  46. The only problem with this is that there is no explicit call to CDocument (?)
  47. when the document is closed (no -- wait -- DUH -- it's called Dispose(!)).
  48.  
  49. So I guess what I'll do is assume that the doc. is open between the time it
  50. is created and disposed of.
  51.  
  52. Is there a better way to do this?  Is there a standard way?
  53.  
  54. What I'm gonna do is this - when I open the document with OpenFile(),
  55. i'll keep track of the fact that it was opened in CTOCApp.  Then 
  56. when I close it, i'll mark that it was closed.  Whenever CTOCApp recieves a
  57. OpenDocument messaeg, it will first check that the file is not currently open.
  58.  
  59. Does this sound OK?  What do you think is the best way to list the files I 
  60. have open -- SFReply, filename, magic cookie ... ?
  61.  
  62. BTW, how many people are actually programming with the TCL anyway?
  63.  
  64. joshr@kronos.arc.nasa.gov
  65.  
  66.  
  67.  
  68.  
  69. -- 
  70. ----------------------------------
  71. #include <std/disclaimer.h>     Josh Rabinowitz, Mac TCL programmer
  72. joshr@kronos.arc.nasa.gov
  73. "'I see', said the blind carpenter, as he picked up his hammer and saw".
  74.