Anonymous wrote:
well i was just asking to get more information about the tool...ok for an example if their is a command which opens a file and if someone has deleted the file then obviously when the script runs it fails to execute or run the file(as it is deleted)...so what to do now in this case in order to skip a error like this and let the script execute the other commands after this following error....any idea???
You need to fix your spelling.
If your OS locks the file, then perhaps you can still make use of it. If not, then it's gone. But the script will still want to do something.
Here's what you do.
READ THE DOCUMENTATION. Each function has a good description not only what it does, what options there are, but possible error information in case this stuff happens. A little planning goes a long way.
In the case of FileRead, it states
Quote:
ErrorLevel is set to 0 if the load was successful. It is set to 1 if a problem occurred such as: 1) file does not exist; 2) file is locked or inaccessible; 3) the system lacks sufficient memory to load the file.
So simply by seeing this if Errorlevel >0 then an error happened, and depending on it's value we know how to react.
Code:
FileRead, var, somefile
if (ErrorLevel = 1)
msgbox File does not exist
else if (ErrorLevel = 2)
msgbox File is locked or inaccessible
else if (ErrorLevel = 3)
msgbox Cannot open due to lack of resources
else {
;it's just fine, work with it.
}
;or
FileRead, var, somefile
if ErrorLevel
return
;anything following, it read the file.