Re: try error oddity
Re: try error oddity
- Subject: Re: try error oddity
- From: Rick Bargerhuff alias cougar <email@hidden>
- Date: Sat, 26 Jul 2003 19:28:01 -0400
On Saturday, Jul 26, 2003, at 17:36 US/Eastern, John Delacour wrote:
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?
Hey John,
Here is what is happening...
Variable a is intact up to the point you call on error a... a is being
undefined by the on error statement. Even though you have
no error occurring, the statement is still being executed but since
there is no error, a is wiped out.
If you place {a,b} at the end of the code for the second snippet of
code, it errors as well saying "The variable a is not defined.".
The reason why you get 2 for the second batch of code is because
applescript is returning the result of the
last executed statement which is 1+1.
set {a, b} to words of "OK OK"
try
1 + 1
The result for applescript is 2 (set theresult to the result)
on error a
This is erasing a for some reason.
end try
try
1 + 1
The result for applescript is now 2 (set theresult to the result)
on error b
end try
{a, b}
a and b are not defined but the result if we were to ask for is 2
--> The variable a is not defined.
The below code is the same as the above code except you
are not requesting for the values of a ({a,b})
set {a, b} to words of "OK OK"
try
try
1 + 1
on error a
end try
try
1 + 1
on error b
end try
end try
Hope that helps,
Rick Bargerhuff alias cougar
Programmer / Developer / Computer Specialist
Personal Email: email@hidden
Personal Website :
http://mywebpages.comcast.net/cougar718
_______________________________________________
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.