Re: Variable Ponderance
Re: Variable Ponderance
- Subject: Re: Variable Ponderance
- From: Ben Waldie <email@hidden>
- Date: Thu, 30 Sep 2004 14:01:58 -0400
On Sep 30, 2004, at 1:37 PM, Paul Berkowitz wrote:
Lists, records, dates and script objects are "data sharing" - i.e.
mutable
in place.
Yes, this is interesting. I know I've encountered this before, but I
just never really questioned it. I'll take a look at the language
guide again to refresh my memory on some of the various aspects of
scope and data sharing.
Furthermore, top-level variables are global in scope unless
specifically declared local. So unless you declare y to be local in
your
handler, or at the top level of the script, or both, it's going to be
global.
Yes, although the language guide might lead one to believe otherwise
where it says...
"AppleScript assumes that all variables defined at the top level of a
script or within its subroutines are local unless you explicitly
declare them as global."
Also, this concept is a little bit interesting as well. In the script
below, x is treated as a global variable. This is evident if you run
the script more than once.
try
display dialog x
on error
set x to 1
end try
Though, if it were truly global, wouldn't this script run successfully?
Does it only become global once the script has finished executing?
try
display dialog x
on error
set x to 1
doSomething()
end try
on doSomething()
x -- This line will cause an error
end doSomething
-Ben
Benjamin S. Waldie
President & CEO
Automated Workflows, LLC
610.935.0652
=============================================
AppleScript and Workflow Automation
Consulting - <http://www.automatedworkflows.com>
AppleScript Info - <http://www.applescriptguru.com>
AppleScript Training - <http://www.applescripttraining.com>
=============================================
_______________________________________________
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