On Mar 4, 2011, at 21:17, Artemio González López wrote:

> On Mar 3, 2011, at 4:15 PM, Christiaan Hofman wrote:
> 
>> Try running some applescript in AppleScript Editor, and see what commands 
>> fail. It seems it's an AppleScript problem, and AppleScript is extremely 
>> fragile and it's behavior (i.e. its many bugs) change for every OS version. 
>> Have a look in the displayline script 
>> (Skim.app/Contents/SharedSupport/displayline) to see what AppleScript it 
>> uses. In particular the "go to" command. Try something like:
>> 
>> tell application "Skim"
>>      tell document 1
>>              go to line 1000
>>      end tell
>> end tell
>> 
>> 
>> and:
>> 
>> 
>> set theFile to POSIX file "/path/to/your/file.pdf"
>> tell application "Skim"
>>      activate
>>      open theFile
>>      tell document 1
>>              go to line 1000
>>      end tell
>> end tell
>> 
>> 
>> and:
>> 
>> 
>> set theFile to POSIX file "/path/to/your/file.pdf"
>> set theSource to POSIX file "/path/to/your/file.tex"
>> tell application "Skim"
>>      activate
>>      open theFile
>>      tell document 1
>>              go to line 1000 from theSource
>>      end tell
>> end tell
> 
> Dear Christiaan,
> 
> I've done a few tests with AppleScript, with mixed (and quite baffling) 
> results. The first script you mention in your message works flawlessly 
> (replacing "go to line 1000" by "go to TeX line 1000", but that was just a 
> typo in your email, I think). However, the second and third ones fail 
> miserably. More precisely, the file is opened if it wasn't already, but its 
> corresponding window stays on the first page, or (if the file was already 
> open) its window is selected, but stays wherever it was. Moreover, the script 
> never completes (it just says "Running" in the results log) unless stopped by 
> hand (and it takes quite a while to stop, actually). In fact, from the event 
> log one can see that the only events processed are (if the file in question 
> is /Users/Shared/myfile.pdf)
> 
> tell application "Skim"
>       activate
>       open file "Mac OS X Lion:Users:Shared:myfile.pdf"
> 

Why do you get the 'file' specifier? Such a specifier is generally broken (at 
least in 10.6 and earlier, I have little hope 10.7 fixes this; this is an 
AppleScript bug). You should create a variable using 'POSIX file', preferably 
outside the 'tell' block (inside the 'tell' block it's not guaranteed to work, 
and Apple has hinted that in the at some point it may not work). Also, a 'POSIX 
file' specifier should not be automatically expanded into a 'file' specifier as 
above, it did so before 10.5 which I remember always gave serious problems.

> (By the way, I tried the same thing withe files whose path didn't contain 
> spaces, like "/Volumes/TRANS-IT/foo.pdf", and the behavior was the same). So 
> it seems to me the problem is either with the open command or with the 
> filename format Skim is expecting, but (since no errors are reported in the 
> system log) I have no idea of what the heck is going on. Any suggestions?
> 
> Thanks again,
> 
> Artemio
> 

It certainly should not do this. This really sounds like a bug in Cocoa 
Scripting or basic AppleScript support, as the "open" command is provided by 
Apple. 

Does it also do this when there is no "go to TeX line" after this? Or when it 
is replaced by some other AppleScript, in particular some standard AppleScript 
commands? 

I would urge you to file a bug report with Apple about this 
(http://bugreport.apple.com), also reporting explicit AppleScripts to reproduce 
the problem, best is when they rely only on standard commands (otherwise Apple 
may wrongly say it's not their problem), and if you can reproduce similar 
problems with Apple's own scriptable apps it really is clear. I think we can 
only hope Apple fixes this before the actual release.

Christiaan

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Skim-app-users mailing list
Skim-app-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-users

Reply via email to