Monday, February 27, 2017

#1 2005-10-13 04:10:23 pm

julifos
Administrator
From: MalasaƱa, Madrid
Registered: 2002-11-20
Posts: 2014

What are "libraries" and how do I use them?

Libraries are collections of handlers, also called "user commands", which you keep in separate scripts.

You can load them when needed and use the functions contained within such library. If we have this library, containing 1 handler, in a script called "whatever.scpt":

Applescript:

on userName()
   text returned of (display dialog "What is your name?" default answer "")
end userName

We can use the userName handler from our main script as follow:

Applescript:

set myLibrary to (load script alias "path:to:whatever.scpt")
tell myLibrary to userName()

You can also load libraries "statically" by declaring the library as a property:

Applescript:

property myLibrary : load script alias "path:to:whatever.scpt"

You can visit the home page of the libraries' guru Has here, though libraries themselves are now hosted here.

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.029 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)