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

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Try to create a directory twice
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
  Forms, Dialogs;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
Form1: TForm1;
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);

  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}
Hide full unit code
   Directory created OK
   Repeat creation failed with error 183
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page