Re: Who has that property?
Re: Who has that property?
- Subject: Re: Who has that property?
- From: Axel Luttgens <email@hidden>
- Date: Fri, 11 Nov 2005 11:18:23 +0100
Scott Babcock wrote:
>[...]
>
>This is why I need to be able to determine a property's actual
>container.
>
Thanks for having taken the time to reply, Scott.
I'm still not sure to fully grasp how you organize and, more
importantly, maintain your system; I must be a very visual guy... ;-)
has wrote:
> Scott Babcock wrote:
>
>> [...]
>> The script-runner applet runs text script files
>> with the 'run script' event, which means that the script files are
>> compiled into script objects whose parent is the applet.
>
> Not unless you instruct them to do do, or your script editor has
somehow screwed up all your contexts again. Scripts compiled within 'run
script' take the AppleScript object as their parent, unless you specify
another via their 'parent' properties.
>
>> [...]
>
> Two recommendations:
>
> 1. Enquire about your context pollution problems on LNS's SD mailing
list and/or their support desk. If SD is the culprit as you suspect
(it's definitely not AS's doing), [...]
Hmm... yes and no.
The problem is to know how exactly Scott organizes his business, but it
could well be that he doesn't face context clashes due to SD, just an
old standard AS behavior that gets often overlooked when doing trials in SE.
That behavior may be described by this rather elusive excerpt from the
ASLG: "The default parent property for any script that doesn’t
explicitly declare one is the default target application—usually, the
application that is running the script, such as the Script Editor".
So, let's see if this makes some sense with the "run script" command.
First, define:
A sub-library (saved as SubLib.scpt)
====================================
property SomeProp : "Initial value from SubLib"
return me
on test()
display dialog "From SubLib: " & SomeProp
display dialog "From SubLib: " & parent's SomeProp
end test
A library (saved as Lib.scpt)
=============================
property SomeProp : "Initial value from Lib"
property SubLib : ""
set SubLib to load script alias "Path:To:SubLib.scpt"
return me
on test()
SubLib's test()
display dialog "From Lib: " & SomeProp
display dialog "From Lib: " & parent's SomeProp
end test
A main script
=============
property SomeProp : "Initial value from Main"
property Lib : ""
set Lib to load script alias "Path:To:Lib.scpt"
test()
on test()
Lib's test()
display dialog "From Main: " & SomeProp
end test
Then, run the main script in SE:
(dialog) From SubLib: Initial value from SubLib
(error dialog) NSCannotCreateScriptCommandError
Clearly, script object SubLib doesn't like the idea of having a parent
with a property named SomeProp...
Now, save the main script as an applet and double-click its icon:
(dialog) From SubLib: Initial value from SubLib
(dialog) From SubLib: Initial value from Main
(dialog) From Lib: Initial value from Lib
(dialog) From Lib: Initial value from Main
(dialog) From Main: Initial value from Main
So, it appears that both Lib and SubLib are now able to get (as well as
set) a parent's property; in both cases, the returned value is the one
from the applet that loaded (directly and indirectly) the libs.
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden