property mct : 0
set mylst to {1, 2, 3}
try
with timeout of 1 second
if (my mct) mod 2 is equal to 0 then -- switch between these two error possibilities every other run
set a to item 4 of mylst -- an error
else
mount volume "afp://server/volume" as user name "name" with password "password" -- a timeout error
end if
end timeout
on error number num
if num is equal to -1712 then -- a timeout error
say "timeout"
else -- a different type of error
--end timeout -- it'd be nice to put this here but it won't compile
beep {}
end if
end try
set my mct to (my mct) + 1
It seems that if my try block involves the possibility of errors other than timeout, I’ll sometimes end up with an unbalanced “end timeout” statement.
How bad is that, does AppleScript magically account for the missing ‘end timeout’?
Or is the only reasonable solution to move the ‘on timeout/end timeout’ pair OUTSIDE the try block?
I just wrote a short script to demonstrate the problem.
The real issue occurs when I use “Tell aplication…” inside a try block with a ‘on timeout/end timeout’ pair in the mix too.
Any non-timeout error will skip the ‘end timeout’ part of the code as it goes to the error handler.
Despite my Applescript references ignoring that possibility, it seems to me that that’s sloppy code, asking for trouble.
Is there some reason that ignoring the termination of ‘on timeout’ is OK?
-I see the post I was replying to has just disappeared.
OK, I’ll hope this post makes my question a little clearer, and wait for another reply.