• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Who has that property?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who has that property?


  • Subject: Re: Who has that property?
  • From: has <email@hidden>
  • Date: Mon, 7 Nov 2005 11:27:10 +0000

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 'lib 2 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

  • Prev by Date: Re: How to work with XML data using System Events?
  • Next by Date: Re: How to work with XML data using System Events?
  • Previous by thread: Who has that property?
  • Next by thread: RE: Who has that property?
  • Index(es):
    • Date
    • Thread