LOTUSSCRIPT LANGUAGE
For example:
Sub TestHand Dim num As Single num! = 1 Print num! / 0 End Sub Sub SuperHand On Error Resume Next Call TestHand() ' When control returns to SuperHand upon an error ' in TestHand, execution continues at this Print statement. Print "Continuing after calling sub TestHand." Exit Sub End Sub Call SuperHand() ' Output: ' Continuing after calling sub TestHand.
Similarly, when the statement Resume Next appears within an error-handling routine for an error that occurred in a lower-level procedure, "Next" refers to the next statement in the calling procedure.
The statement Resume 0, or simply Resume, in an error-handling routine means to re-execute the line where the error occurs, even if that line is in a lower-level procedure.
' The sub SuperHand calls the sub TestHand with an argument ' of 0, which produces an error. The error is handled by an ' error-handling routine in the caller, the sub SuperHand. ' Handling the error includes resetting the call argument ' to 1, and then calling TestHand with this argument. On the ' second call no error occurs. Sub TestHand(num As Integer) Dim num2 As Single If num <> 0 GoTo ProcPo Print "Call argument to sub" & _ "TestHand is 0; will generate error." ' There's no error-handling routine in sub TestHand for ' division-by-zero, so control returns to the calling sub ' SuperHand when the next statement is executed. num2! = num% / 0 ' This Print statement is not executed at all. Print "Continue here after division-by-zero error?" Exit Sub ' Come here if call argument is nonzero. ProcPos: Print "Call argument to sub TestHand is nonzero" & _ " (no error)." Exit Sub End Sub Sub SuperHand Dim numIn As Integer ' A division-by-zero error not handled in sub TestHand ' is handled by the error-handling routine at DivZero. On Error GoTo DivZero Call TestHand(numIn%) Exit Sub DivZero: Print "Handling division-by-zero error." numIn% = 1 ' Re-execute the statement that caused the error ' being handled. This will be the statement Call ' TestHand(numIn%) above. The call argument is now 1. Resume 0 End Sub Call SuperHand() ' Output: ' Call argument to sub TestHand is 0; will generate error. ' Handling division-by-zero error. ' Call argument to sub TestHand is nonzero (no error).
See Also