Re: Variable Tendencies
Re: Variable Tendencies
- Subject: Re: Variable Tendencies
- From: kai <email@hidden>
- Date: Mon, 3 Apr 2006 19:04:51 +0100
On 3 Apr 2006, at 18:16, Michelle Steiner wrote:
On Apr 3, 2006, at 10:09 AM, Christopher Nebel wrote:
Some variables are persistent -- it depends on their scope.
Global variables are; local ones aren't. (The fact that global
variables persist was, I'm pretty sure, not intended by the
original designers, but it's not going to change.)
That brings up a point: is there any benefit to declaring global
variables as properties considering that global variables are
persistent, and will remain that way?
There are a couple of possible benefits directly related to Jack's
original question, Michelle.
Firstly, a property can be defined at compile time. So if we wanted
the user to input a value or to make a choice only once, the first
time a script was run, we could simply use something like:
--------
property auftragFolder : missing value
if auftragFolder is missing value then set auftragFolder to choose
folder with prompt "Select Auftrag folder:"
display dialog (auftragFolder as Unicode text) (* for demo purposes *)
--------
(With a global variable, we'd probably have to use a rather clumsy
try statement.)
Another advantage is that script properties can generally be accessed
externally. So, instead of writing a variable to a separate file and
then getting a script to read it, the value of a script property
could be modified directly:
--------
set scriptFile to alias "full path to:a script containing:a property
labelled:auftragFolder" (* modify as required *)
set loadedScript to load script scriptFile
set loadedScript's auftragFolder to choose folder with prompt "Select
new Auftrag folder:"
store script loadedScript in scriptFile replacing yes
--------
---
kai
_______________________________________________
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