Re: Scope
Re: Scope
- Subject: Re: Scope
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 14 Dec 2002 19:23:56 -0800
OK, I seem to have got it fixed. As I suspected I needed to access the
unused variable before returning it. Simply doing this:
return {my var1, my var2, my var3}
rather than
{var1, var2, var3}
from the ControllerHandler in script B is good enough. var3, which had never
been accessed by the handler (it's only required if it hits an error, not
otherwise), and which was returning - for most users - as its initial
'missing value' instead of the value as set by script A before the handler
in B began, now gets returned with the new value just as it should.
This does not happen with short scripts such as the ones I've been using as
examples. It does not even happen for every user: for some reason it was not
happening to me OMM, although the just-previous version did fail that way.
All the users (so far) who had the strange error yesterday report back that
my newest version returning 'my var3' works fine; no errors any more.
It should not be necessary to refer to a global or property by 'my' when
there is no local or other instance of it. And script length should be
irrelevant. Therefore, it seems to be a bug.
I'm sorry that the problem is so complicated, and the scripts so long, that
it was hard to explain it clearly here.
--
Paul Berkowitz
On 12/14/02 12:02 PM, I wrote:
>
**THE PROBLEM:
>
>
What seems to be happening is that the 'missing value' properties in
>
script B do get set to the passed values, and get used by script B. The
>
script would break otherwise. But because var3 never once gets modified
>
during script B's run (as long as there are no faulty data items there) it
>
does not seem to be "registered" properly by the ControllerHandler there.
>
So when it returns
>
>
{var1, var2, var3}
>
>
to the main script, it returns the properly modified values for var1 and
>
var2 (which could only be modified if it first had its var1 and var2
>
re-set from missing value to the values passed by script A in the first
>
place), but instead of passing back
>
>
{}
>
>
or var3, the value passed to that property by script A before any handler
>
was called, it returns
>
>
missing value
>
>
its _unmodified_ initial value before script A passed the {} value to it!
>
>
So the 'if' block the the very end of the script A runs, since var3 is now
>
'missing value' rather than {} as it's supposed to be, and then when it
>
tries to 'count var3', it can't count 'missing value' so you get the
>
mysterious '0 doesn't understand the count message' error.
>
>
This is very bad. It seems like a bug to me. How can I make sure that this
>
doesn't happen? Perhaps start ControllerHandler by
>
>
set {var1, var2, var3} to {var1, var2, var3}
>
>
or
>
>
set {my var1, my var2, my var3} to {my var1, my var2, my var3}
>
>
to "initialize" them?
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >Re: Scope (From: Emmanuel <email@hidden>) |