Re: try error oddity
Re: try error oddity
- Subject: Re: try error oddity
- From: Axel Luttgens <email@hidden>
- Date: Wed, 27 Aug 2003 09:28:59 +0200
John Delacour wrote about a month ago:
Can someone explain why I get these results? I would not expect a and
b to be undefined if there is no error but on;y redefined if there
is. Is that an illogical expectation?
set {a, b} to words of "OK OK"
try
1 + 1
on error a
end try
try
1 + 1
on error b
end try
{a, b}
--> The variable a is not defined.
[...]
Don't know if this has already been answered (again very late at reading
the list) but here follows an attempt...
Seems to be an amusing scoping matter.
Try this variant to see what I mean:
-- Here, we should be implicitely declaring
-- global a, as well as initializing it
set a to "OK"
try
1 + 1
-- But here we are declaring local variable a...
on error a
end try
my a
--> "OK"
a
--> error (undefined)
Just to ensure that we really have created two distinct entities named
"a" through our (implicit) run handler:
set a to "OK"
try
1 / 0
on error a
end try
my a
--> "OK"
a
--> "Can't divide 1.0 by zero"
Anyway, nice to meet you again,
Axel
(hope Paul and Has won't kill me for having dared such a thing..)
_______________________________________________
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.