access to application's globals by handlers within script object

Even though the specific example shown below belongs to Studio, I am hoping the solution comes from Applescript in general …

Between Rosenthal’s Applescript book and Studio’s Mail example I thought I was beginning to understand how the handlers within a script object accessed the parent application’s globals and handlers … but apparently I am confused (more so than a cow standing on astroturf …


property parentGlobal: 0
script myScript
	on choose menu item theFile
		my parentHandler(theFile)
	end choose menu item
end script

on parentHandler(theFile)
	-- change the app's parentGlobal here
	my anotherHandler() -- this looks at the value parentGlobal
end parentHandler

on anotherHandler()
	--
end anotherHandler

set myFile to whatever

set script of myFile to myScript

This has been a real pain to find out why, with choosing the menu item (myFile), the parentGlobal always starts out = 0, when I know that I have changed it outside the script object = myScript??? I’ve changed it globally, but when the script myScript is run, the parentGlobal is re-initialized to 0.

Any ideas?