Getting formatted references from Bookends

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

Getting formatted references from Bookends

Post by Jon »

Bookends 11.2.9 and later has the ability to respond to AppleEvents and send a formatted reference to the requesting application. Other developers (like those of Tinderbox) can take advantage of this to get reference metadata from Bookends. You can also do this via AppleScripts. Below is the section from the User Guide that tells you how this feature works (with an example AppleScript that will work with Script Editor at the end).

Jon
Sonny Software

------------------------------------------------------------

You can use Script Editor, or if you are a developer an IDE like XCode, to create scripts or code that asks Bookends to return formatted references on demand. To obtain a formatted reference, send Bookends an AppleEvent with the event id of "GUID". A 4 letter event type is required but can be any characters -- it is recommended that you use the Creator Code for the calling application, e.g. "ToyS" for Script Editor. Two optional parameters let you specify which format to use, and whether you want the result returned as plain text or RTF.

Here are the parameters:


Required: the event class. Any 4 character string will do. We recommend you use the Creator Code for your application (e.g. "ToyS" if you are using Script Editor to send the AppleEvent).

Required: the event id (GUID), and the direct parameter is the unique ID of the reference you want.

Optional class: "RRTF". This contains a boolean value that tells Bookends whether you want the result returned as plain UTF-8 text (false, or unspecified) or RTF (true).

Optional class: "TEXT", in an AppleScript referred to as "string", contains the name of the format, encoded as UTF-8, that you want Bookends to use. If the format is not specified, or cannot be found, Bookends will use the currently selected format in Bookends.

Here is an example AppleScript that returns the reference having the unique ID 21864 formatted for APA 6th edition (as RTF styled text):

tell application "Bookends"
«event ToySGUID» "21864" given «class RRTF»:"true", string:"APA 6th edition"
end tell
jtth
Posts: 5
Joined: Tue Sep 16, 2014 12:37 pm

Re: Getting formatted references from Bookends

Post by jtth »

Is there a way to do this but with the reference currently selected in Bookends? (Say, scriptable from a TextExpander shortcut when Bookends is in the background to insert the citation directly into the foremost program?)
Jon
Site Admin
Posts: 10038
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Getting formatted references from Bookends

Post by Jon »

Yes. We've added a lot since this post was made. See the user guide (starting on p. 21). I think you're looking for

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

Jon
Sonny Software
jtth
Posts: 5
Joined: Tue Sep 16, 2014 12:37 pm

Re: Getting formatted references from Bookends

Post by jtth »

Thank you. For those wondering to combine the functions described in the user guide:

Code: Select all

tell application "Bookends"
	return «event ToySGUID» («event ToySRUID» "Selection") given «class RRTF»:"true", string:"APA 6th Edition"
end tell
Post Reply