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
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
MyErr = ERR
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