• 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: Creating list references in handlers. Bad code or bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating list references in handlers. Bad code or bug?


  • Subject: Re: Creating list references in handlers. Bad code or bug?
  • From: Helmut Fuchs <email@hidden>
  • Date: Fri, 14 Sep 2001 17:50:12 +0200

At 10:26 Uhr -0400 14.09.2001, Victor Yee wrote:
I think that the problem is a matter of scope. References can only refer to top-level or global varaibles.

Not completely true.

Run this:


on theHandler()
local theData

set theData to {theList:{1, 2, 3}}
set theListReference to a reference to theList of theData

return contents of theListReference
end theHandler

theHandler()
<<

Here, clearly some property of a LOCAL variable is referenced. And it still works - thanks to the magic of "data sharing".

A reference generated by "a reference to" is simply a description of how to access an object in AppleEvent terms.

If you ask for "a reference to theData" then a reference is generated which simply says: look up the object named "theData" in global scope. This fails.

But there are other references, which are internal to AppleScript. These are used to achieve the data sharing concept. Such a reference is automatically included in theListReference above. The reference from the handler above works like this: look up the property named "theList" from {theList:{1, 2, 3}}. And this always works!

HTH,

Helmut


  • Follow-Ups:
    • Re: Creating list references in handlers. Bad code or bug?
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Sudden unusual behaviour with tell app commands
  • Next by Date: TV Tuner Channel Changing
  • Previous by thread: Re: Creating list references in handlers. Bad code or bug?
  • Next by thread: Re: Creating list references in handlers. Bad code or bug?
  • Index(es):
    • Date
    • Thread