[fpc-pascal] Dear FreePascal

J├╝rgen Hestermann juergen.hestermann at gmx.de
Wed Apr 21 07:10:11 CEST 2010

>>     {$i-} reset(dat);{$i+}
>>      if ioresult <>0 then
>>         rewrite(dat);
> Although not wrong, the purpose of this construction is not clear to me.
> In every case you will end up overwriting all data in the file.
> In that case you could simply do with a  rewrite(dat). The reset(dat)
> is really not necessary.
> If the file exists, rewrite will effectively clear it's contents. If
> the file dowes not exist, rewrite will create an empty file for you.

Although I don't see the purpose of the above code snippet there is a difference between existing and non-existing file:
If dat exists (and can be opened without error) then the rewrite is not done. So in this case dat is only opened for reading and existing data is not deleted (yet).

More information about the fpc-pascal mailing list