Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handler query - exchanging values



On 30/06/06 6:53, Malcolm Fitzgerald wrote:


On 29/06/2006, at 11:31 PM, Yvan KOENIG wrote:


Just matter of curiousity. For my own needs, I prefer to pass the needed values from one handler to an other one.


what need for the " set variables as global" in the handlers ?
I thaught that defining them as global in the main script was sufficient.
For see, I removed the two " set variables as global" instructions from the handlers and didn't sew any odd effect.
Am'I missing something ?


try this
-----------------------------
global apples, pears

set apples to 3
boo()
hoo()  --> error: the variable apples is not defined

on boo()
    set apples to 1
end boo

on hoo()
    display dialog apples
end hoo

-----------------


Something changed recently (time to carefuly read the release notes?).

This has always worked, and is of course the way one would expect globals to be accessed:

  -- OK up to 10.4.7
  boo()
  hoo()

  on boo()
     global apples
     set apples to 1
  end boo

  on hoo()
     global apples
     display dialog apples
  end hoo

But previously, one had terrible lexical scoping clashes that required to be extremely careful:

  -- OK up to 10.3.9
  -- (fortunately) fails since 10.4.x
  global apples

  boo()
  hoo()

  on boo()
     set apples to 1
  end boo

  on hoo()
     display dialog apples
  end hoo

Thanks for having shown that point,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Re: Handler query - exchanging values (From: Malcolm Fitzgerald <email@hidden>)
 >Re: Handler query - exchanging values (From: Malcolm Fitzgerald <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.