Script Library appears to be not working

I am trying to take advantage of the new Mavericks feature and set up a “Script Libraries”. (I copied and pasted so spelling could be verified.)

So I have a file ~/Library/Script Libraries/TID.scpt. It has the content:


on SaveTID(newTID)
	set currentTID to AppleScript's text Delimeter
	set AppleScript's text Delimeter to newTID
	return currentTID
end SaveTID

on RestoreTID(oldTID)
	set AppleScript's text Delimeter to oldTID
end RestoreTID

from, http://macosxautomation.com/mavericks/libraries/examples.html it show one can use either


tell script "TID" to set oldTID to SaveTID("=")

or


use script "TID"
set oldTID to SaveTID("=")

The first example works. the second generates a error:

Anyone see something I did wrong?

The use command imports terminology – that is, any terms defined in an associated .sdef file – but it doesn’t import handler names. Try this:

use tidScript: script "TID"
set oldTID to tidScript's SaveTID("=")

I hope that’s not what it really says – you need:

set currentTID to AppleScript's text item delimiters

Hi,

first of all there is a syntax typo in your code. It’s

AppleScript text item delimiters

but in the scope of AppleScript you can write

on SaveTID(newTID)
	set currentTID to text item delimiters
	set text item delimiters to newTID
	return currentTID
end SaveTID

on RestoreTID(oldTID)
	set text item delimiters to oldTID
end RestoreTID

To use the script as library you have to implement the use statement and tell the script to do the handler

use script "TID"
tell script "TID" to set oldTID to SaveTID("=")

Okay,

I looked further at the website, I mentioned above. The problem will work with a tell block.


tell script "TID"
	set oldTID to SaveTID("=")
end tell

I will have to look further into the use statement.

Just to clarify: if you use the tell statement like that, you don’t need the use statement at all.

This is what started my journey, today. http://www.macstories.net/stories/applescript-automator-and-automation-improvements-in-mavericks/. In this article is shows a naked or undecorated use of use.

That’s right. But you will see that he also defined terminology in an .sdef file; that’s the stuff that gets read in via a use command. Without that (and sometimes even with that), you still need to use a tell or equivalent.

Wrote a small tutorial here if need any more explanation I will expand the post.