Re: variables vrs properties
Re: variables vrs properties
- Subject: Re: variables vrs properties
- From: "Stockly, Ed" <email@hidden>
- Date: Wed, 5 Jan 2011 12:38:07 -0600
- Acceptlanguage: en-US
- Thread-topic: variables vrs properties
>> What exactly are the advantages/disadvantages to using properties over
>> variables?
>>
>> Property € global within scope
>> € retains value until script is recompiled
That's not the case. A property retains its value between runs. Within the
context of Script Editor it will retain it's value when recompiled, but
after the script is compiled and saved, the saved copy does not retain the
value set before compiling.
>>
>> Variable € global within scope only if declared global
>> € doesn't retain value between executions
Globals do retain value between executions.
Some have good reasons not to use properties and globals, mostly related to
the issues of saving changes to a script after execution, but for most
scripters those issues do not outweigh the convenience and speed advantages
that using properties provide.
(Note, even if you reset a property to its original value, if it's been
changed during execution, the script/applet is re-saved anyway.)
I've noticed some experienced programmers have a knee-jerk reaction to the
term "global" and avoid using them in AppleScript because they are
associated with bad programming. Some use properties instead. Of course
properties have the same scope as "globals" and properties are just as
good/evil as globals in appleScript.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden