Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ErrorMode error mode suppress info information off on
Suppressing errors with the ErrorMode function must be done with great care. When an error occurs, the processing of the entire line is cancelled. Setting the ErrorMode() to @OFF or @NOTIFY allows execution to resume when errors occur. When you turn off error reporting, various parts of the original line may not have been executed.
Here's an example:
ErrorMode(@off) ; This line will cause a "file not found" error when error mode is on. ; A is set to @FALSE by default A = FileCopy("XXXXXXXXXXXX","XXXXXXXXXXX",@FALSE) ; Now there is a NOT (!) symbol in front of the FileCopy. Nonetheless, if a error occurs ; A is still set to @FALSE - not @TRUE as might be assumed. A = !FileCopy("XXXXXXXXXXXX","XXX#XXXXXXXX",@FALSE)
For this reason, ErrorMode() must be used with a great deal of care. The function for which the errors are being suppressed should be isolated from other functions and operators as much as possible.
e.g., BAD FORM:
In this instance, when the copy has an error, the entire if statement is canceled. Execution begins (erroneously) at the next line, and states that the copy succeeded. Then a fatal error occurs when the "else" is found, since it does not have a matching if statement:
ErrorMode(@OFF) if FileCopy(file1,file2,@FALSE) Message("Info", "Copy worked") else Message("Error","Copy failed") endifCORRECT FORM:
In this case, the FileCopy is isolated from other statements and flow control logic. If the statement fails, execution can safely begin at the next line. the variable "a" will contain the default value of zero that a failed assignment returns.
Article ID: W13056
Filename: ERRORMODE Suppressing Errors Important Info.txt
File Created: 1999:04:15:16:51:28
Last Updated: 1999:04:15:16:51:28