LastError

Returns the most-recent error encountered during the current WIL program.

Syntax:

LastError ( )

Parameters:

(none)

Returns:

(i) most-recent WIL error code encountered.

 

WIL errors are numbered according to their severity. "Minor" errors go from 1000 through 1999. Moderate errors are 2000 through 2999. Fatal errors are numbered 3000 to 3999.

 

Depending on which error mode is active when an error occurs, you may not get a chance to check the error code. See ErrorMode for a discussion of default error handling.

 

Every time the LastError function is called, the "last error" indicator is reset to zero.
A full listing of possible errors you can encounter in processing a WIL program is in Appendix B.
Of course, if you use the LastError function to trap errors, then extensive script testing -- including all error conditions -- is highly recommended.

Example:

ErrorMode(@OFF)
LastError( )
FileCopy("data.dat", "c:\backups\*.*", @FALSE)
ErrorMode(@CANCEL)
If LastError( ) == 1006
   Message("Error", "Please call Tech Support at 555-9999.")
EndIf
Message("LastError"," Done.")
See Also:

Debug, ErrorMode, IntControl 73, Errors