August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.clearError()
The clearError() method of the File object clears the file error status and the value returned by the eof() method.
Listing 8.72 opens a file for reading. If the operation returned an error, the error is written to the page. If there was an error, it is cleared after writing it.
<SERVER>
// Open a log file
var myLog = new File("/data/logs/today.log");
// Open the log file for reading
myLog.open("r");
if (myLog.error() == 0) {
// Perform actions on file
}else{
// Write out the error
write('Error: ' + myLog.error());
// Clear the error
myLog.clearError()
}
// Close the file
myLog.close();
</SERVER>
|
Read now
Unlock full access