[OS X TeX] TeXShop macro "Select class options"
Jonathan Kew
jonathan_kew at sil.org
Mon Aug 30 10:47:25 CEST 2004
On 30 Aug 2004, at 9:01 am, Will Robertson wrote:
> Basically I'd like not to have to embed my script ever deeper within
> error-catching if statements; I think I'm missing something basic -
> I'd expect to be able to to do something like this:
>
> on run
> subroutine1
> subroutine2
> subroutine3
> do some final stuff
> end
>
> with the code in each subroutine going something like this:
>
> on subroutine1
> do some stuff
> if error1, exit run
> end
>
> and so on.
>
Could you use the "try ... on error ..." construct to help?
Along the lines of
on run
try
subroutine1
subroutine2
subroutine3
finalStuff
on error errText number errNum
if errNum = .... -- test for errors that you want to handle
else -- deal with unknown errors in a generic way, perhaps
end if
-- perhaps some cleanup here
end try
reallyFinalStuff
end run
on subroutine1
-- do stuff here
if (something's wrong) then error "Failure in sub1" number 10000 --
raise an error
-- do more stuff
if (another problem) then error "Failure in sub1" number 10000
end subroutine1
etc.
Errors can include other information, too, like a reference to the
object that caused the failure; check the Applescript doc for more
information. I believe you can also do things like nest "try" blocks,
re-throw an error from within the error handler if you want to pass it
up the chain, etc.
HTH,
JK
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
More information about the macostex-archives
mailing list