RE: Who has that property?
RE: Who has that property?
- Subject: RE: Who has that property?
- From: "Scott Babcock" <email@hidden>
- Date: Mon, 7 Nov 2005 11:01:15 -0800
- Thread-topic: Who has that property?
Yes, referring to "lib2 of lib2" directly results in an error.
Try this, though:
set libRef to (a reference to lib2 of lib2)
handler1() of (get contents of libRef)
I've run this code on 10.3.9 and 10.4.2 with Script Editor and Script
Debugger. It works just as I described. I failed to point out the
significance of using a reference to access the inherited property,
although this is the method used in whoHasLib2().
> Date: Mon, 7 Nov 2005 11:27:10 +0000
> From: has <email@hidden>
> Subject: Re: Who has that property?
> To: email@hidden
> Message-ID: <a05200f00bf94deacd603@[82.3.86.249]>
> Content-Type: text/plain; charset="us-ascii"
>
> Scott Babcock wrote:
>
> >[ Library1 ]
> >----------------------------------------
> >| property lib2 : missing value
> >| ...
> >----------------------------------------
> >
> >[ Library2 ]
> >----------------------------------------
> >| ...
> >----------------------------------------
> >
> >[ MainScript ]
> >----------------------------------------
> >| property lib1 : missing value
> >| property lib2 : missing value
> >|
> >| on run
> >| set my lib1 to load script alias "Mac OS
X:Users:scoba:Library1"
> >| set my lib2 to load script alias "Mac OS
X:Users:scoba:Library2"
> >| set lib2 of my lib1 to a reference to my lib2
> >| ...
> >| end run
> >----------------------------------------
> >
> >Library2 doesn't have a lib2 property, but because of the scoping
rules
> >of AppleScript properties, it's possible for MainScript to refer to
lib2
> >of lib2.
>
> AppleScript's scoping rules for properties should not permit this, and
OMM
> adding a 'lib2 of lib2' to the end of the main script's run handler
> results in the expected "Can't get lib2" error, 'handler1() of lib2 of
> lib2' similarly result in an error, albeit a confusingly phrased one.
A
> couple possibilities: the code you're seeing this on is not actually
the
> same as what's shown above, or there's a bug in your version of AS.
>
>
> > Looking into the Library2 script object, AppleScript discovers
> >that it has no lib2 property, so it checks the in parent of Library2
-
> >which is MainScript itself.
>
> In your above example, Library2's parent is the AppleScript object.
That
> information is baked in when a script object is created (in this case,
at
> compilation time).
>
> By default, a top-level script [object]'s parent is the AppleScript
> object, while a script object declared using a nested 'script ... end
> script' block takes the enclosing script object as its parent.
Inserting a
> 'parent' property statement allows a different parent to be specified.
> Apart from some weirdness due to the differences in how static-bound
> variable lookups vs. dynamically-bound variable/handler lookups work,
it's
> all quite logical.
>
> has
> --
> http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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