Examples Delphi

procedure TForm1.OpenButtonClick(Sender: TObject);
{open user-specified file but check that it's not too big}
{NOTE I don't think Delphi puts a restriction on the size of
files that Memo components can handle, does it..?}
var
TooBig : Boolean;
begin
TooBig := False;
with OpenDialog do
begin
if Execute then
begin
try
MainMemo.Lines.LoadFromFile(Filename);
except on EInvalidOperation do
TooBig := True;
end; {end try...except}
if TooBig = True then
begin
ShowMessage('This file is too large to load into the Text Editor');
end {if}
else
begin
HistoryList.Add(Filename);
Caption := 'Richards Text Editor - ' +
ExtractFilename(Filename);
SaveDialog.Filename := Filename;
Filename := '';
end; {else}
end; {if}
end; {with}
end;