ON ERROR GOTO ErrTrap
...
ON ERROR GOTO 0
...
ON ERROR RESUME NEXT
...
ON ERROR GOTO ErrTrap
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Announcement
Collapse
No announcement yet.
RESUME Questions
Collapse
X
-
Guest repliedLance, Thank you!!!
Could you be a little more specific about Q3.
------------------
Leave a comment:
-
-
All error traps must have a RESUME <linelabel>.
ie,
Code:FUNCTION MyFunc.... ON ERROR GOTO MyFuncTrap .... MyFuncResumePoint: EXIT FUNCTION MyFuncTrap: ' handle error here RESUME MyFuncResumePoint END FUNCTION
Instead, you simply need to write your code to either handle errors as they occur (no trap or use RESUME NEXT, and check ERR as necessary) or write your error trap to branch back above the line you wish to resume again - you can have several RESUME <Linelabel> depending on the state of ERR, etc. This way permits you to keep the code size down and performance up, whilst constructing as much or a little error testing as you need yourself.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
-
RESUME Questions
I have a couple of questions in regard to error handling.
Q1 - The manual notes that you must terminate a error trap with a RESUME statement. Could you not just fall out of the sub/func as well or do you have to RESUME?
Q2 - I see noted a RESUME label and a RESUME Next but not a RESUME. How would you try the offending line again?
Q3 - If you want to cancel error trap for a couple lines of code you can use the RESUME NEXT. How do you start the error trap again for that sub/func?
Code:Private Sub MySub() On Error Goto ErrorRoutine (some code....................) 'stop error trap On Error Resume Next (some code....................) On Error Goto 0 (some code....................) ErrorRoutine: (some code....................) End Sub
Thanks.Tags: None
-
Leave a comment: