A question about Libraries

I have a number of handlers that I use repeatedly on various scripts. I’d like to use them from a library instead of having a copy in each individual script.

They all use positional handler syntax.

Is it possible to define Library terminology for handlers which have positional parameters?

I don’t care about handler descriptions and parameter descriptions, I just want to be able to run the handlers without changing every handler call from to add a Library reference.

You can use any handler syntax. But you will have to target the library. So this:

my doSomething()

will need to be:

use someLib : script "Lib Name"
...

someLib's doSomething()
-- or:
tell someLib to doSomething()

Thanks Shane. I was hoping to avoid the solutiion of changing all my handler references, but I guess there’s no avoiding it.

I have one more question.

Can I make a reference from one Library script to Library script, and if so, how?

example:

In ~/Library/Scripts, I have two script files, Utilities.scpt and Loqqing.scpt

Utilities.scpt defines the handler JoinListToString(List,Delimiter)

Loqqing.scpt defines the handler LoqResults(Data), inside is a reference to JoinListToString

set A to JoinListToString(List,Delimiter)

In the main script I have


use scripting additions
use U: Utilities.scpt 
Use L : Loqqing.scpt

L's LoqResults("SomeData")

Running this gives an error that says that Loqqing.scpt doesn’t understand JoinListToString(List,Delimiter) - can’t find it.

Fine, so I change the reference in Loqqing’s LoqResults(Data) to be:
U’s JoinListToString(List,Delimiter)

I get the same error.

Then I add this to the start of Loqqing.scpt


use scripting additions
use U: Utilities.scpt 

Same error.

I try change the reference in Loqqing.scpt to be “V” instead of “U”
Same error.

I tried

 load script Utilities.scpt 

and then changed the reference to be: Utilities’s JoinListToString(List,Delimiter)
Same error.

Is there anyway to make this work?

The alternative is to put every handler in in same library script.

The first post in this thread:

https://forum.latenightsw.com/t/property-values-not-being-globally-available/1730

shows how it can be done.