While trying to enhance a large script I discovered an odd behavior.
Here is a bare script demonstrating it.
use theLib : script "simple lib"
set theResult to theLib's sortAList:{2, 8, 3, 9, 4, 0, 1}
In ~/Libraries/Script Libraries/ I stored a short library file named « simple lib.scptd »
It’s perfectly recognized by the AppleScript Editor which formatted correctly the two instructions.
The problem surfaced when I introduced a third instruction calling a Standard Additions function :
use theLib : script "simple lib"
set theResult to theLib's sortAList:{2, 8, 3, 9, 4, 0, 1}
set needUpdate_mettreAjour to (localized string "LA26" in bundle path to application "Finder")
This time, the Editor refused to compile.
It stopped with the word « string » highlighted in « localized string “LA26” »
and the warning stated :
→ « , » prévu mais nom de classe trouvé.
As I am pig headed I made an other test with :
use theLib : script "simple lib"
set theResult to theLib's sortAList:{2, 8, 3, 9, 4, 0, 1}
set the clipboard to "azerty"
This time the script was correctly compiled but don’t shout Bingo.
When I ran it, I got a really puzzling result :
The event log displayed :
→ error number -1728 from clipboard
AND
Résultat :
error “Il est impossible de régler clipboard à "azerty".” number -10006 from clipboard
Yes, you read correctly, two different error numbers.
It seams that there is a serious smell of bug but I’m not 100% sure.
Maybe I made something wrong but why ?
Last thing, at first I tried to store the library in the local Library folder (not the user one) : /Library/Script Libraries
hoping that the library would be usable from every account.
Nada, it’s not seen from the Scripts Editor and it’s why I was forced to move the file in the user’s one ~/Libraries/Script Libraries/
At this time it’s not a huge problem for me because I have two alternate schemes to achieve what I had to do but it may become boring some of these days.
May you check on a machine running the system in English ? After all, maybe the oddity strikes only on French systems.
Yvan KOENIG (VALLAURIS, France) jeudi 6 mars 2014 16:32:25