Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>errorcode()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ERRORCODE()
 Identifies a DOS error that has occurred previously
------------------------------------------------------------------------------
 Syntax

     ERRORCODE([<lKeep>]) --> nDosErrorCode

     Warning!  This function requires DOS 3.1 or higher.

 Argument

     <lKeep>  When this parameter is designated as .T., the function
     returns the internal error code memory value.

 Returns

     ERRORCODE() returns a value that represents the error code that occurred
     during the most-recently executed DOS function.

 Description

     If you do not specify a parameter or if the parameter is .F., then
     ERRORCODE() calls the DOS error function (INT 21h, 59h) and returns the
     code value stored for the most-recent error.  DOS stores the most-recent
     error code until a new error occurs.  If your operation is error free,
     this value is not  reset.

     To take this situation into account, ERRORCODE() can alternatively be
     called with <lkeep> set to .T..  If called like this, the error code
     always relates to the last CA-Clipper Tools function that was executed.
     Since the respective CA-Clipper Tools function behavior is stored at an
     internal memory location, it is impossible to implement this option with
     regular CA-Clipper functions.

 Note

     .  You can find a table that contains all the error codes in
        Appendix B:  Error Codes.

 Examples

     .  This example attempts to copy a file.  If an error occurs,
        FILECOPY() returns a value of 0 which offers no specific error
        information:

        nBytes  :=  FILECOPY("TEST\TEST.PRG", "NEW.PRG")
        IF nBytes = 0 .AND. ERRORCODE() = 3
           ? "File path not found!"
        ENDIF

     .  An example of two file copies is illustrated below:

       The first file is unsuccessful, but the second file is not:

        FILECOPY("XXXXX.TXT", "YYYY.TXT")
        ? ERRORCODE(.T.)                  // 2 - File not found
        ? ERRORCODE()                     // 2 - File not found
        FILECOPY("SOURCE.TXT", "TARGET.TXT")
        ? ERRORCODE(.T.)                  // 0 - Last Tools
                                          // function was successful
        ? ERRORCODE()                     // 2 - File not found

     Warning!  Any CA-Clipper Tools function that contains a DOS call
     resets the internal variable retrieved by setting <lKeep> .  The
     following call series never returns the desired result, because the
     first call of ERRORCODE() contains a DOS call:

     ? ERRORCODE(), ERRORCODE(.T.)        // Result: x, 0


See Also: ERRORACT() ERRORBASE() ERRORORG()

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