Extended AppleScript support in 11.3.1 and later

Users asking other users for AppleScripts that work with Bookends.
Post Reply
Jon
Site Admin
Posts: 8659
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Extended AppleScript support in 11.3.1 and later

Post by Jon »

Bookends 11.3.1 and later have much more robust AppleScript support than earlier versions. You can ask Bookends to return the unique ids of references in any group (including the built-in groups), as well as directly perform SQL searches and get the unique ids of references that match. These capabilities are fully explained in the User Guide in the section Getting reference information from Bookends via AppleEvents.

Below are listed AppleScript examples (without explanation -- see the User Guide for that) that work with the current version of Bookends:

Get unique ids of the selected references or references in a group

tell application "Bookends"
     return «event ToySRUID» "Recent papers"
end tell


Get unique ids of references found with an SQL search

tell application "Bookends"
     return «event ToySSQLS» "authors REGEX 'Johnson' "
end tell


Ask Bookends to return formatted references

tell application "Bookends"
     return «event ToySSQLS» "21864" given «class RRTF»:”true”, string:”APA 6th
          Edition”
end tell


Get group names

tell application "Bookends"
     return «event ToySRGPN»
end tell


Ask Bookends to return the contents of a specific field

tell application "Bookends"
     return «event ToySGUID» "21864" given «class RRTF»:”true”, string:”APA 6th Edition”
end tell


Jon
Sonny Software

flips
Posts: 3
Joined: Fri Feb 21, 2014 6:22 am

Re: Extended AppleScript support in 11.3.1 and later

Post by flips »

This is great stuff! :)

However, I seem to be struggling to understand some basic Applescript concepts. I tried searching reference material and tutorials.

Basically I'm trying to query for all entries (or later all in a particular group), and then query for the entries of that list, using the result from the first query. (Each part works separately.) So, trying to do something like this:

Code: Select all

set listOfEntries to {}
tell application "Bookends"
	return «event ToySRUID» "All"
	copy result to end of listOfEntries
	return «event ToySGUID» listOfEntries given «class RRTF»:"false", string:"RIS"
end tell
I tried a variety of ways, read about looping and variable assignments etc., but I think there's something really basic I'm not getting ... :shock: (Even two consecutive tell statements don't seem to work, I just get the results from the first ...)
flips 8)

Jon
Site Admin
Posts: 8659
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Extended AppleScript support in 11.3.1 and later

Post by Jon »

I'm only slightly conversant in AS, but what does listOfEntries look like? Is is one long string, or are the id's separated by commas or Return characters (and if Returns, what ASCII, 10 or 13)?

Jon
Sonny Software

flips
Posts: 3
Joined: Fri Feb 21, 2014 6:22 am

Re: Extended AppleScript support in 11.3.1 and later

Post by flips »

I don't know. I tried adding "print listOfEntries", but no change.
And I can't find standard debugging tools in AppleScript Editor, like running in steps or inspecting variables.

Events list indicates that everything stops after the first return (the triple dots are just me shortening the output):

Code: Select all

tell application "Bookends"
	«event ToySRUID» "All"
		--> "23167
44047
...
36962"
end tell

Result:
"23167
44047
...
36962"
The same also if I enter just this:

Code: Select all

tell application "Bookends"
	return «event ToySRUID» "All"
	return «event ToySGUID» "79665,70234,65595" given «class RRTF»:"false", string:"RIS"
end tell
or this:

Code: Select all

tell application "Bookends"
	return «event ToySRUID» "All"
end tell
tell application "Bookends"
	return «event ToySGUID» "79665,70234,65595" given «class RRTF»:"false", string:"RIS"
end tell
So, I assume I'm lacking some very basic AppleScript knowledge/understanding. :roll:
flips 8)

Jon
Site Admin
Posts: 8659
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Extended AppleScript support in 11.3.1 and later

Post by Jon »

The problem is that the 2nd request isn't being run. After the first return you're done. This works for me

set listOfEntries to {}
tell application "Bookends.debug"
get «event ToySRUID» "All"
copy result to end of listOfEntries
return «event ToySGUID» listOfEntries given «class RRTF»:"false", string:"RIS"
end tell

flips
Posts: 3
Joined: Fri Feb 21, 2014 6:22 am

Re: Extended AppleScript support in 11.3.1 and later

Post by flips »

Ah, yes, thanks! :D
"get" is the command I was looking for.
Had a feeling that return would end the loop, but I didn't know what else to put there.
(Yes, I'm a total n00b when it comes to AppleScript.)
flips 8)

Post Reply