Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - on error do install a runtime error handler routine http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 on error do         Install a runtime error handler routine
------------------------------------------------------------------------------
 Syntax
   on error do xProc

 Arguments
   xProc is a function to install as custom error handler.

 Description
   The on error do command causes execution of xProc when a runtime
   error occurs.

   The error routine is called if Force detects a condition that could
   jeopardize data. Once the on error do routine is called, the error
   procedure terminates the program.

   Regardless of close commands in your error procedure, Force closes all
   open files. The number of the last error can be found in the __errcode
   system variable.

   To avoid critical errors that invoke the DOS "Abort, Retry or Ignore?"
   error, use the critical() procedure. Design Force programs to avoid
   error conditions rather than reacting to errors as they arise. For
   example, before opening a database file, check to see if it exists.

 Example
   #define EXAMPLE_SYSTEM
   #include example.hdr

   // Use on error do procedure for debugging and critical error trapping
   
   proc ErrorProc
   alert( "Runtime error " + istr( __errcode ) + ";" + emessage(), ;
      " Exit program ", RED_WHITE, BLUE_YELLOW )
   quit
   endproc
   
   proc Test_onerrordo
   on error do ErrorProc                  // install custom error handler
   ? pickcount( 0 )                       // generate an error
   endproc

   proc main
   Test_onerrordo()
   endproc

See Also: on neterr do

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson