Re: AS Library Question
Re: AS Library Question
- Subject: Re: AS Library Question
- From: Shane Stanley <email@hidden>
- Date: Wed, 16 Dec 2015 15:07:03 +1100
On 16 Dec 2015, at 10:31 AM, Stan Cleveland <email@hidden> wrote:
>
> The libraries I use are custom-made for the work here.
In case anyone's interested in the practicalities...
Consider text item delimiters. Those who have used AS for a long time will remember the days where a script you were working on in your chosen editor would error, and the state of TIDs would cause problems in a totally unrelated script. Then at some stage the problem went away. Except it didn't. What changed is that editors started giving each script its own AS component with its own TIDs. In any case, the problem didn't matter in applets, because they have their own AS component instance, but you can still get bitten in scripts run from most scriptable apps (InDesign, Illustrator, BBEdit, probably FileMaker, FastScripts...), which run all scripts from a single AS component instance.
With libraries, the issue effectively involves properties within them. If you change the value of a property in a library, and it's being run from one of the aforementioned apps, the property value will persists until the app quits (or you change it). That means a script using a library will see the property as having the value set by whatever script ran it last (assuming there was one). This doesn't show up in editors, applets or scripts run from the Scripts menu -- they all run each script in its own component instance.
The solution is to basically to be aware of it, and probably avoid properties within libraries where they're not really needed. And you can do things like add some kind of initialization handler that scripts should run first before they call others.
There are also cases where a persistent lib property makes sense. Something like a number formatter in an ASObjC-based lib, or simply where you scripts to share some info.
And if you don't run scripts from within other apps, you can just ignores it.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden