• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Variable Tendencies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable Tendencies


  • Subject: Re: Variable Tendencies
  • From: deivy petrescu <email@hidden>
  • Date: Mon, 3 Apr 2006 17:28:14 -0400


On Apr 3, 2006, at 13:09, Christopher Nebel wrote:

On Apr 2, 2006, at 5:54 PM, deivy petrescu wrote:

On Apr 2, 2006, at 18:23, Mark J. Reed wrote:

First, it's not a stupid question.  What you're talking about is
called "persistence".  AppleScript variables are not persistent.

I agree with the first assertion, it is not a stupid question, but I disagree with the fact that AppleScript variables are not persistent, they are...


Try this at home:
Open SE(*) type the following script
<script>
try
	set x to x + 1
on error
	set x to 1
end try
</script>
keep pressing the run button:

--> 1,2,3,4,...

So yes, variables are persistent.

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.)



--Chris Nebel


The funny thing with AS is that *all* variables in the main script are global by default and all variables in the handlers or script are local by default.
I would think that the behavior of handlers and scripts are the standard behavior , however, I would expect to have to declare a global variable in the main script.
That is, I'd expect the following to cause an error:


<script>
--local x --> this would cause the handler to error

set x to 20
addone(x)
-->22

on addone(y)
	global x
	set y to x + 1
	return y + 1
end addone

</script>

but it does not.


Deivy _______________________________________________ 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
References: 
 >Variable Tendencies (From: Jack Crombie <email@hidden>)
 >Re: Variable Tendencies (From: "Mark J. Reed" <email@hidden>)
 >Re: Variable Tendencies (From: deivy petrescu <email@hidden>)
 >Re: Variable Tendencies (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: XMail and FMPro
  • Next by Date: Re: Folder Actions technical questions
  • Previous by thread: Re: Variable Tendencies
  • Next by thread: Re: Quicktime : save export settings problem
  • Index(es):
    • Date
    • Thread