RE: set variables, in mass
RE: set variables, in mass
- Subject: RE: set variables, in mass
- From: Dennis Cox <email@hidden>
- Date: Wed, 1 Dec 2004 08:01:48 -0600
Title: RE: set variables, in mass
----------
From: halloolli
Sent: Tuesday, November 30, 2004 7:26 PM
To: email@hidden
Subject: Re: set variables, in mass
set a to 0 -- a now has 0
> copy a to b -- b now has 0
is there any difference between set and copy?
olli
It depends on the datatype. For lists, records, dates, and script objects, they are not the same.
For lists, when you assign a variable to a value that is a list, set sets the variable as a reference, copy doesn't, it makes an entirely new object.
Compare the results from these two scripts:
set listOne to {1, 2, 3}
copy listOne to listTwo
set item 3 of listOne to "Saskatoon"
{listOne, listTwo}
set listOne to {1, 2, 3}
set listTwo to listOne
set item 3 of listOne to "Saskatoon"
{listOne, listTwo}
Using set means that any change to one variable is reflected in the other.
The same holds for records, dates and script objects.
For other datatypes, use your preferred command.
For a much better and complete understanding, see Matt Neuberg's "AppleScript, The Definitive Guide".
Dennis
_______________________________________________
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