[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+-------------+############################################################
#+-| ON ERROR DO |---------------------------------------------+##############
#| +-------------+ The ON ERROR DO command causes execution of |##############
#| <Procedure> when a runtime error occurs |##############
#+-------------------------------------------------------------+##############
##############################################################################
##############################################################################
#+--| Syntax |---------------------+##########################################
#| ON ERROR DO <Procedure> |##########################################
#+---------------------------------+##########################################
##############################################################################
##############################################################################
########+---| Description |-------------------------------------------+#######
########| 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 variable, which is defined in the |#######
########| data.hdr header file. |#######
########| ----------------------------------------------------------- |#######
########| To avoid critical errors that invoke the DOS "Abort, Retry |#######
########| or Ignore?" error, use the critical procedure. |#######
########+-------------------------------------------------------------+#######
##############################################################################
##############################################################################
######+--------------------------| NOTE: |-----------------------------+######
######| 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 1 |-------------------------------------------+#########
#########| * Check to see if database exists prior |#########
#########| * to using the OPEN command. |#########
#########| |#########
#########| IF .NOT. EXIST( "my.dbf" ) |#########
#########| ? "Error: Unable to locate database file" |#########
#########| ELSE |#########
#########| |#########
#########| OPEN "my.dbf" ALIAS mine |#########
#########| ENDIF |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * Use ON ERROR DO procedure for debugging and |#########
#########| * critical error trapping. |#########
#########| |#########
#########| PROCEDURE error_proc |#########
#########| ? e_message() && Print the error |#########
#########| && message. |#########
#########| QUIT |#########
#########| ENDPRO |#########
#########| |#########
#########| PROCEDURE force_main |#########
#########| |#########
#########| ON ERROR DO error_proc |#########
#########| |#########
#########| {...} |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
critical
exist()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson