This method is not one provided by RhinoScript. Rather, this is user-definable subroutine that can be used to override RhinoScript's default script cancelling behavior.
When a script is running and the ESC key is pressed, RhinoScript searches for loaded, user-defined subroutine named OnCancelScript. If this subroutine is detected, RhinoScript will automatically run this procedure instead of just printing the "Script cancelled" message.
For more information, see Cancelling Scripts.
OnCancelScript
None
None
Sub TightLoopEscapeTest
For i = 0 to 100000
Call Rhino.Print(i)
Call Rhino.Sleep(0)
Next
End Sub
' User-defined cancel script handler
Sub OnCancelScript
' Do script cancelling operations here...
Call MsgBox("Script Cancelled!", vbOkOnly + vbExclamation, "RhinoScript")
End Sub