1.1.36 $I or $IOCHECKS : Input/Output checking

The {$I-} or {$IOCHECKS OFF} directive tells the compiler not to generate input/output checking code in the program. By default, the compiler generates I/O checking code. This behaviour can be controlled globally with the -Ci switch.

When compiling using the -Ci compiler switch, the Free Pascal compiler inserts input/output checking code after every input/output call in the code. If an error occurred during input or output, then a run-time error will be generated. This switch can also be used to avoid this behaviour.

If no I/O checking code is generated, to check if something went wrong, the IOResult function can be used to see if everything went without problems.

Conversely, {$I+} will turn error-checking back on, until another directive is encountered which turns it off again.

The most common use for this switch is to check if the opening of a file went without problems, as in the following piece of code:

assign (f,’file.txt’);  
rewrite (f);  
if IOResult<>0 then  
  Writeln (’Error opening file: "file.txt"’);  

See the IOResult function explanation in Reference Guide for a detailed description of the possible errors that can occur when using input/output checking.