SmartPascal
$IOChecks
Compiler Directive
When on, an IO operation error throws an exception
1   {$IOChecks Off}
2   {$IOChecks On}
Description
The $IOChecks compiler directive determines whether an exception is thrown when an IO operation encounters an error.
 
{$IOChecks On} default generates the EInOutError exception when an error occurs.
 
{$IOChecks Off} does not generate an exception. Instead, it is the responsiblity of the program to check the IO operation by using the IOResult routine.
Notes
The IOResult routine resets the IO error value to 0 when called.

$IOChecks is equivalent to $I.

This directive can be used multiple times within your code.

The default value is $IOChecks On
Related commands
$I Allows code in an include file to be incorporated into a Unit
IOResult Holds the return code of the last I/O operation
 
Example code : Try to create a directory twice
var
  error : Integer;

begin
  // Try to create a new subdirectory in the current directory
  // Switch off I/O error checking
  {$IOChecks off}
  MkDir('TempDirectory');

  // Did the directory get created OK?
  error := IOResult;
  if error = 0
  then ShowMessage('Directory created OK')
  else ShowMessageFmt('Directory creation failed with error %d',[error]);

  // Try to create the directory again - this will fail!
  MkDir('TempDirectory');
  error := IOResult;
  if error = 0
  then ShowMessage('Directory created OK again')
  else ShowMessageFmt('Repeat creation failed with error %d',[error]);

  // Delete the directory to tidy up
  RmDir('TempDirectory');

  // Switch IO checking back on
  {$IOChecks on}
end;
Show full unit code
   Directory created OK
   Repeat creation failed with error 183