• 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: *Very* strange script / global variable behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: *Very* strange script / global variable behavior


  • Subject: Re: *Very* strange script / global variable behavior
  • From: Neil Faiman <email@hidden>
  • Date: Sun, 27 Feb 2005 17:19:50 -0500

(I'm using AppleScript under Panther 10.3.8, if it is relevant.)

I've experimented some more with this problem, and it looks even weirder than I realized. In particular, it the scripts don't have to be nested to produce strange behavior. Here's an alternative version of the program:

	property theState : 0
	global theScript

	script Inner
		on showTheState()
			display dialog "State " & theState
		end showTheState
	end script

	script Outer
		on initialize()
			set theScript to Inner
		end initialize
	end script

	set x to Outer

	set theState to 1
	tell Outer to initialize()
	tell theScript to showTheState()
	set theState to 2
	tell theScript to showTheState()

This will display "State 0" twice. If you change theState from a property to a global, it will display "State 1" and "State 2" as expected. If you leave theState as a property, and comment out the apparently irrelevant line "set x to Outer", it will now print "State 1" twice!

Can anyone help make sense of this behavior?

Thanks,

	Neil Faiman

_______________________________________________
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


  • Follow-Ups:
    • Re: *Very* strange script / global variable behavior
      • From: Neil Faiman <email@hidden>
References: 
 >*Very* strange script / global variable behavior (From: Neil Faiman <email@hidden>)

  • Prev by Date: Re: Text size of Finder window
  • Next by Date: Re: *Very* strange script / global variable behavior
  • Previous by thread: *Very* strange script / global variable behavior
  • Next by thread: Re: *Very* strange script / global variable behavior
  • Index(es):
    • Date
    • Thread