On 04/29/2017, at 19:31, Jean-Christophe Helary <email@hidden> wrote:
So I guess using use myLib : script "fakeLib"
allows to call the handler through that myLib instead of of script "fakeLib" which is way longer, right?
Right. And your label for the script library can be any non-reserved word.
I thought the terms used by the library were automatically imported with the "use" statement and there was no need to refer to it into the script.
This is true of applications – not script libraries. You are required to use a reference to the library.
Thank you. And, is there a reference to that in the ASLG?
The documentation is not very satisfactory...
I should have mentioned that script libraries with a proper sdef and their own terminology WILL work with a non-referenced use script <myLib> statement.
Here's an example using Shane Stanley's BridgePlus library:
----------------------------------------------------------------------------------- use AppleScript version "2.4" use framework "Foundation" use scripting additions use script "BridgePlus"
set theStr to "Now is the time for all good men to come to the aid of their country." set nsStr to current application's NSString's stringWithString:theStr set asStr to ASify from nsStr -----------------------------------------------------------------------------------
For a script library without an sdef you simply have to put up with the reference in order to call it's handlers.
A use statement in that context is essentially a more compact form of the old load script protocol:
----------------------------------------------------------------------------------- set fLb to load script alias ((path to library folder from user domain as text) & "Script Libraries:FLb.scptd:")
set _data to "Now is the time for all good men to come to the aid of their country." set newStr to fLb's cng(".", "•", _data) of me -----------------------------------------------------------------------------------
But as of Mavericks the macOS knows where to look for libraries and doesn't need an explicit path.
You have to watch out for terminology imported with use statements, because it doesn't always work the way you think it should.
Try running this from Script Debugger and/or Script Editor:
----------------------------------------------------------------------------------- use application "Finder" set winName to name of front window -----------------------------------------------------------------------------------
The terminology space tends to be different than you think.
|