No announcement yet.

Error Code Routine

  • Filter
  • Time
  • Show
Clear All
new posts

    Error Code Routine

    I tried to write an error subroutine that would reset itself to retry after err 70, error 71, and error 53. If the disk is not ready or the file is write protected, I get the error message, but I have to start the program all over again to clear the error. I tried $error all on and it did not help. I tried resume and resume next, but they didn't help.
    I also tried err =0 (It was unclear from the pb manual how to use this or where to place it).
    I would include the code here, but it is about 30 lines long. If you know of a shorter way to reset after errors, please let me know.

    You might try something like this

    on error goto GeneralErrorTrap
    ' some line(s) that will generate an error
    on error goto 0 'Reset to no trap

    Enumber = err 'extract the generated error number
    if Enumber = 53 or Enumber=70 or Enumber=71 then
    resume 0 'Try the error line again
    ' resume something else
    ' or end the program or whatever
    end if

    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.


      Are you using PowerBASIC/DOS or FirstBasic? If PB/DOS, which version?

      Please review the "Event/Error Trapping" chapter in the PB/DOS Users Guide (Page 195 of the V3.5 manual) - it shows the correct way to construct error handlers, both global and local.

      Also be sure to check out the ERRTEST and ERRCLEAR functions for when you need to explicitly clear an error from the ERR (and related) system variables.

      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      mailto:[email protected]