unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
const
FileName = 'toto.txt';
var
f: TextFile;
i: LongInt;
begin
{$I-}
// closeFile(f);
AssignFile(f, FileName);
Rewrite(f);
{$I+}
i := IOResult;
if i <> 0 then
Label1.Caption := 'Error: ' + i.ToString
else
Label1.Caption := 'No error';
end;
end.