QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 Return to Index  

Complaint about ON ERROR GOTO

October 11 2004 at 11:04 AM
  (Login Mac36)


Response to Error codes

FAQ014 = How can I trap errors using ON ERROR?

The more I think about it, the more I regret that the QBasic designers invented the ON ERROR GOTO concept!

There should have been two simple commands
     ERROR TRAP
     ERROR NOTRAP

After processing an ERROR TRAP statement, QBasic would not stop on errors, but just set ERR to the error codes that neil posted (and which can be found in QBasic HELP) and continue.

After processing an ERROR NOTRAP statement, QBasic would stop on errors and print out the error as is done now.

But that is not the case. :-(

However, by coding
     DIM SHARED MyErr
in any main program, along with
     GetMyErr:
     MyErr = ERR
     RESUME NEXT
after the last SYSTEM command, the equivalent is achieved.

This is ERROR TRAP
     MyErr = 0: ON ERROR GOTO GetMyErr

This is ERROR NOTRAP
     ON ERROR GOTO 0

Mac

 
 Respond to this message