Is there a workaround for no finally block

Usually when I write automation code I wrap it in a try/catch/finally statement. The finally block of the statement will contain any “clean up code” that might need to run regardless of whether or not a exception was through. For example, I might clear a reference or close a dialog in the finally block since I would want those things to happen regardless.

Since SenseTalk doesn’t support the finally the block for the try/catch statement does anyone have any way to duplicate its functionality. In other words is there some way to guarantee that code in a script will be run regardless of whether or not an exception is thrown?


Well, you can put your cleanup in both the catch and at the end of your try block (or immediately after your catch block). If it’s a collection of cleanup stuff then of course you will be better off grouping that into it’s own handler.

	if random(2) equals 1 then  throw myproblem
catch myException
	throw myException -- or log 
end catch

to cleanupStuff
	put stuff1
	put stuff2
	put stuff3
end to

Thanks that’s exactly what I was looking for.