On 10/01/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
What I don't understand though is why pdfFile is not the full path to the file to begin with, and why check_open does not work with full pathnames. Since Brad is the mastermind behind this part of the bundle, I hope he'll find some time to chime in.
Maybe I should answer this (as best I can), since I wrote check_open.
check_open doesn't use AppleScript as such, but it does use AppleEvents. The event is sends is built using AEBuildAppleEvent from the template
'----':obj{form:enum('name'),want:type('docu'),seld:TEXT(@),from:null()}
which has the same effect as AppleScript along the lines of
tell application "App" to get document "doc".
This form of request just uses the document name; essentially the name that's used as the window title. This can indeed cause false positives when you have two documents in different folders with the same name.
The original application of check_open was in the Watch document command, where it's used to terminate the watcher when the document window is closed. In this situation, the crucial thing is to avoid false NEGATIVES. However, in the situation under discussion here, it's more important to avoid false positives!
Does anyone know whether there's a reasonably reliable way to detect whether a document is open that does not suffer from this problem?
Robin