Re: Scope
Re: Scope
- Subject: Re: Scope
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 12 Dec 2002 13:20:33 -0800
Sorry, I really do define var1 right at the top of script A. Like this (and
note the more accurate error handler structure):
Script A:
global var1
set var1 to 0
try
repeat with i from 1 to 100
set var1 to var1 + 1
-- do stuff
end repeat
set f to load script alias "path:to:script B"
tell f to set var2 to someHandler()
on error errMsg number errNum
my ErrorHandler(errMsg)
end try
on ErrorHandler(errMsg, errNum)
display dialog errMsg
set g to load script alias "path:to:script C"
tell g to set var3 to anotherHandler(var1)
end try
On 12/12/02 12:56 PM, I wrote:
>
Script A:
>
>
global var1
>
>
try
>
--do stuff
>
set f to load script alias "path:to:script B"
>
tell f to set var2 to someHandler()
>
>
on error errMsg number errNum
>
set g to load script alias "path:to:script C"
>
tell g to set var3 to anotherHandler(var1)
>
display dialog errMsg
>
end try
>
>
>
Script C: -- no run handler, only one handler here:
>
>
on anotherHandler(var1)
>
--do stuff with var1
>
end anotherHandler
>
>
>
>
A system error (not a display dialog) appears at or near the end of the
>
script run:
>
>
The variable var1 is not defined.
>
>
How can it not be defined? I'm wondering if script B, which indeed does not
>
know about var1, is somehow imposing its scope on the error handler in
>
script A if another error is actually occurring during script B's run? Is
>
this possible? Would adding 'my' to the error handler help?
>
>
>
on error errMsg number errNum
>
set g to load script alias "path:to:script C"
>
tell g to set var3 to anotherHandler(my var1)
>
display dialog errMsg
>
end try
>
>
>
It's going to be very hard to replicate the original error since I don't
>
know what it is. But var1 is certainly always defined in script A and is
>
passed to anotherHandler(var1) in script C as a parameter, so it should be
>
defined there at all times - there is no other handler in script C. I can't
>
see anywhere that var1 is not defined, except in script B which never refers
>
to it. (I've checked.) And I don't have a separate local variable of the
>
same name anywhere in script A either.
>
>
Does anyone know what's going on?
--
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: | |
| >Scope (From: Paul Berkowitz <email@hidden>) |