Try~Catch~End Try
Carries out exception handling.
Try
<Target Statement for Error Detection>
Catch
<Statement at the time when the Error occurs>
End Try
Parameters
<Target Statement for Error Detection>
|
The statement in which the error is to be detected (statement).
|
<Statement at the time when the Error occurs>
|
The statement to be executed when an error is detected (statement).
|
Return Value
None.
Description
The processing to be carried out when a Macro Error occurs can be defined.
When an error occurs between the Try - Catch commands(<Target Statement for Error Detection>), the command between the Catch - End Try (<Statement at the time when the Error occurs>) is executed.
The error that occurs between Catch - End Try is not considered to be a target error and normal error handling is carried out.
Try - Catch - End Try Commands can be nested.
Moving control from outside the select block to the inside or moving control from inside it to the outside using statements such as the Goto statement is not possible.
The kind of error which occurs between Catch - End Try can be identified by using the Errno command.
The command which generated the error between Catch - End Try can be specified by using the Errcmnd$ command.
Example
Writing data to a file.
*DATAWRITE
Try
Open "/C0/DATA.DAT" for OUTPUT as #1
Print #1, DATA$
Close
Catch
' In the case where the error is generated by the "Open" command.
If ERRCMND$ = "Open" Then
Print "Unable to open file"
' In the case where the error is generated by the "Print" command.
Elseif ERRCMND$ = "Print" Then
Close
Print "Writing failed"
Endif
End Try