> On 30 Nov 2020, at 10:41, Christiaan Hofman <[email protected]> wrote:
>
>
>
>>
>> Maybe I don't understand what I should be doing, but the script doesn't seem
>> to work for me when a single entry is selected in the .bib file's window.
>> Here's what I did that causes the error:
>>
>> (1) select one line in the .bib file window. See screen shot:
>>
>> <PastedGraphic-1.png>
>>
>> (2) Switch over to Script Editor
>>
>> (3) Run the script that Christiaan suggested.
>>
>> (4) I get this result:
>>
>> <PastedGraphic-3.png>
>>
>> The error appears to occur at the line:
>>
>> if count the_pubs is 1 then
>>
>
> That’s AppleScript being really dumb again Add an “of” after the “count” and
> it works (count of the_pubs).
>
> Christiaan
>
Here’s a version with some additions to handle special cases more gracefully:
tell application "BibDesk"
if (count documents) is 0 then return missing value
set the_pub to publication of front window
tell front document
if the_pub is missing value or external of the_pub then
set the_pubs to its selection
if (count the_pubs) is 1 then
set the_pub to first item of the_pubs
end if
end if
if the_pub is missing value or external of the_pub then
set the_name to its name
set the_url to file URL of its file
else
set the_name to title of the_pub
set the_url to export using text
"<[email protected]/>" for the_pub
end if
end tell
return "[" & the_name & "](" & the_url & ")"
end tell
BTW, in the next release you could replace the long export line with
set the_url with item URL of the_pub
Christiaan
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users