Compiler Directive
When on, an IO operation error throws an exception
1   {$IOChecks Off}
2   {$IOChecks On}
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.
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
 Author links

 Download this web site as a Windows program.

Example code : Try to create a directory twice
  error : Integer;

  // Try to create a new subdirectory in the current directory
  // Switch off I/O error checking
  {$IOChecks off}

  // 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!
  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

  // Switch IO checking back on
  {$IOChecks on}
Show full unit code
   Directory created OK
   Repeat creation failed with error 183
'); document.write('
'); document.write('
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page