The f$I-g or f$IOCHECKS OFFg 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, f$I+g will turn error-checking back on, until another directive is encountered which turns it o again.
The most common use for this switch is to check if the opening of a le went without problems, as in the following piece of code:
assign (f,'file.txt');
{$I-} rewrite (f); {$I+} if IOResult<>0 then begin Writeln ('Error opening file: "file.txt"'); exit end; |
See the IOResult function explanation in Reference guide for a detailed description of the possible errors that can occur when using input/output checking.