Re: Applescript Studio setting variables
Re: Applescript Studio setting variables
- Subject: Re: Applescript Studio setting variables
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 01 Feb 2002 05:01:40 -0500
on 02-01-31 5:10 PM, Timothy Bates at email@hidden wrote:
>
What defines scope in an AStudio app?
Within one script, it's the same as AppleScript generally.
>
What is the scope of vars in multiple scripts within a single app?
No scope -- you can't see anything in another script. The way to do this is
through indirection. Use Load Script to load the "foreign" script, or a
script object within it, into a property in the "local" script, then tell
the property to do whatever the foreign script or script object knows how to
do.
There are some issues with this. For example, properties in the foreign
script and the loaded copy of it may have the same name, but in fact they
are independent. Changing the value of one does not change the value of the
other. Using Store Script to save the changed property values back to the
the original foreign script doesn't work, if the foreign script is also in
the application bundle, because scripts in the application bundle are
read-only. So you have to take care with your architecture.
To find the foreign script in the application bundle, use the AS Studio Main
Bundle application property and Path For (not Path To) event, with the new
POSIX File class. And don't forget that the file extension of a script
changes from .applescript to .scpt when it is compiled.
Details are available in the archives for Apple's applescript-studio mailing
list.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont