• 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: copy & set statments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: copy & set statments


  • Subject: RE: copy & set statments
  • From: "Ted Wood" <email@hidden>
  • Date: Sun, 21 Oct 2001 21:27:17 -0700

The short of this is as follows:

a) 'copy' places a copy of the value into the variable:

copy x to 5 -- x gets 5
copy y to x -- y gets 5

b) 'set' places an address to the value (if possible) into the
variable. The exception to this is when you 'set' a variable to a
literal value, as in the 'set x to 5' line below:

Set x to 5 -- x gets 5
Set y to x -- y gets the address of x
-- if x changes, y sees
the new value

c) 'a reference to' copies a reference (or address) into the variable.
This can be used for many object in AppleScript, such as files, items in
a list, words in a paragraph, etc.

set x to (a reference to word 2 of paragraph 3)
-- x gets 'word 2 of paragraph 3'
copy (a reference to word 2 of paragraph 3) to x
-- x gets the actual value of word 2 of paragraph 3
-- note how copy's result was different because of its
nature
set y to item 2 of theList
-- y gets 'item 2 of theList', it the item changes, y sees
it
copy (a reference to item 2 of theList) to y
-- y gets the actual value of item 2 of theList
-- if item 2 changes, y doesn't see it


Hope that helps.


-----Original Message-----

References: 
 >Re: copy & set statments (From: email@hidden)

  • Prev by Date: Re: hash arrays and other mysteries
  • Next by Date: Re: copy & set statments
  • Previous by thread: Re: copy & set statments
  • Next by thread: Re: copy & set statments
  • Index(es):
    • Date
    • Thread