• 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 statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy & set statements


  • Subject: Re: copy & set statements
  • From: Timothy Bates <email@hidden>
  • Date: Tue, 23 Oct 2001 11:00:42 +1000

I believe the information below is not correct?

set theCat to {"woody", "hungry"}

myHandler(theCat)
return theCat

-->>{"woody", "hungry"}

on myHandler(myList)
set myList to "a"
end myHandler

To get the behaviour implied (where a handler deals with the original copy
of a list), you need to say

set theCat to {"woody", "hungry"}

myHandler()

theCat

on myHandler()
global theCat
set theCat to "a"
end myHandler

On 22/10/01 11:17 PM, "Nigel Garvey" <email@hidden>
Nigel Garvey wrote on Sun, 21 Oct 2001 15:54:21 +0100:
>
>> This is something to remember when passing a list or a record as a
>> parameter to a handler. The local variable inside the handler is a local
>> copy of the pointer to the original structure, not a local copy of the
>> structure itself. If you want to fool around with the structure's innards
>> and still have the original intact when the handler returns, use the
>> 'copy' comand first:
>>
>> on myHandler(myList)
>>
>> -- Reassign the variable to a local copy of the list
>> copy myList to myList
>>
>> -- etc.
>>
>> end myHandler


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

  • Prev by Date: Re: copy & set statements
  • Next by Date: Re: Folder Actions in OS X.
  • Previous by thread: Re: copy & set statments
  • Next by thread: Re: copy & set statments
  • Index(es):
    • Date
    • Thread