Why can’t I share a global variable between two scripts in the same project?
In my main script:
global isSaved
on will finish launching theObject
set isSaved to false
end will finish launching
In another script (split out primarily to reduce clutter in an increasingly long and complicated script):
global isSaved --including or excluding this line makes no difference
on choose menu item theObject
set objName to name of theObject
if objName is "menu_new" then
if isSaved is false then display dialog "File not saved"
end if
end choose menu item
If I reference “isSaved” in the main script, it works fine. But in the other script (which holds all my menu actions) it just tells me that the variable is not defined.
Anyone have a fix for this? I could just suck it up an combine the scripts into a single script but it seems silly for Apple to provide a way to divide your code up but not let those pieces exchange data. Oy…
Thanks!!