neviem síce či je to dobre, ale tak takto nejak som to urobil:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a:integer;
vstup:textfile;
implementation
{$R *.dfm}
function sucin:integer;
begin
if a>1 then begin
a:=a-1;
sucin:=sucin + a;
end else begin
read(vstup,a);
sucin:=a;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Assignfile(vstup,'cisla.txt');
Reset(vstup);
Readln(vstup,a);
showmessage(IntToStr(sucin));
Closefile(vstup);
end;
end.