home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!mips!swrinde!elroy.jpl.nasa.gov!ames!kronos.arc.nasa.gov!joshr
- From: joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91)
- Newsgroups: comp.sys.mac.programmer
- Subject: tcl question
- Summary: how do I know if a document has been closed?
- Keywords: oop, tcl, object oriented, documents
- Message-ID: <1992Jul30.222601.8743@kronos.arc.nasa.gov>
- Date: 30 Jul 92 22:26:01 GMT
- Sender: joshr@kronos.arc.nasa.gov
- Followup-To: joshr@kronos.arc.nasa.gov
- Distribution: comp.sys.mac.programmer
- Organization: NASA/ARC Information Sciences Division
- Lines: 58
- Nntp-Posting-Host: kronos-arclan.arc.nasa.gov
-
- Hey netters,
-
- I have a somewhat tcl specific question here which I'll bet money is
- not a FAQ. On second thought, maybe it is, but here goes.
-
- I'm writing an application that shows a table of contents. The app can be
- launched with appleevents from hypercard. What I'm trying to do is the
- following: if the user launches the app with a ceratain table of contents (toc)
- and then goes back to hypercard and launches it again, the application
- will open the file twice. What I want is that when the user
- launches it the second time, the application would realize that
- that file is already being looked at (has a current CDocument associtaed
- with it) and not open it again.
-
-
- My first guess was to check CDocument's field itsSupervisor, like this
-
- itsSupervisor->itsDependents->NthItem(i)->GetClassName(aStr255)
-
- then when I knew what CDocuments were dependent on the application, I could
- check each's window's name to figure out what file they were associated with.
-
- The probelm is, itsDependents turns out to nbe a protected member, so I
- can't access it directly through CDocument.
-
- Here are some ways of doing this I thought up, and their pitfalls.
- Your input is welcome.
-
- The most elegant way would be to simply keep track of which files were opened
- and closed in a CList assosiated with CTOCDoc, my descendent of CDocument.
- The only problem with this is that there is no explicit call to CDocument (?)
- when the document is closed (no -- wait -- DUH -- it's called Dispose(!)).
-
- So I guess what I'll do is assume that the doc. is open between the time it
- is created and disposed of.
-
- Is there a better way to do this? Is there a standard way?
-
- What I'm gonna do is this - when I open the document with OpenFile(),
- i'll keep track of the fact that it was opened in CTOCApp. Then
- when I close it, i'll mark that it was closed. Whenever CTOCApp recieves a
- OpenDocument messaeg, it will first check that the file is not currently open.
-
- Does this sound OK? What do you think is the best way to list the files I
- have open -- SFReply, filename, magic cookie ... ?
-
- BTW, how many people are actually programming with the TCL anyway?
-
- joshr@kronos.arc.nasa.gov
-
-
-
-
- --
- ----------------------------------
- #include <std/disclaimer.h> Josh Rabinowitz, Mac TCL programmer
- joshr@kronos.arc.nasa.gov
- "'I see', said the blind carpenter, as he picked up his hammer and saw".
-