Re: copy & set statements
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