Finally
From REAL Software Documentation
Method
Contains code that will run after a method or function is finished, even if a RuntimeException has occurred.
Syntax
//REAL Studio statements
Catch
[Finally]
//code that executes even if runtime exceptions were raised
End [ Try ] Changed 5.5
Notes
Sometimes a method needs to do some cleanup work whether it is finishing normally or aborting early because of an exception. The optional Finally block at the end of a method or function runs after its exception handlers, if it has any. Code in this block will be executed even if an exception has occured, whether the exception was handled or not. However, the code in the Finally block does not execute if the Try block contains a Return. For example, you can write:
Sub SomeFunction()
//some RB code here...
Finally
//some more code that will always execute
//some RB code here...
Finally
//some more code that will always execute
See the entries for the Sub and Function statements.
Examples
This simple example shows a Finally block that executes even after an exception.
Try
Raise New RuntimeException
Finally
//Executes even though the exception is not handled
MsgBox ("Finally")
End Try
Raise New RuntimeException
Finally
//Executes even though the exception is not handled
MsgBox ("Finally")
End Try
