unit read_and_display_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  arrstr=array [1..5] of string;    // define own type NB!!!
  TForm1 = class(TForm)
    btnRead: TButton;
    redt1: TRichEdit;
    btnDisplay: TButton;

    procedure FormCreate(Sender: TObject);
    procedure btnReadClick(Sender: TObject);
    procedure btnDisplayClick(Sender: TObject);

     private
    { Private declarations }
  public
    myfile:TextFile;
    sline:string;
    inommer:Integer;
    k:Integer;
    arrles: arrstr;
    procedure lees(var arrles:arrstr);     //define own procedure
    procedure vertoon (var arrles:arrstr); //define own procedure
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.FormCreate(Sender: TObject);
var
  j:Integer;
begin
  redt1.Lines.Clear;    //initialize
  for j:= 1 to 5 do
    arrles[j]:= '';     //initialize the array (list of variables)
end;

procedure TForm1.lees(var arrles: arrstr);
begin
  k:=0;
  Assignfile(myfile,'hande.txt'); //working with a textfile
  Reset(myfile);
while not Eof(myfile) do
  begin
    inc(k);
    Readln(myfile,arrles[k]);     //reading from textfile and putting
  end;                            //value in list(array)
closefile(myfile);
end;

procedure TForm1.vertoon(var arrles: arrstr);
var
j:Integer;
begin
for j := 1 to k do
  redt1.Lines.Add(arrles[j]);         //displaying the content of the array(list
end;

procedure TForm1.btnReadClick(Sender: TObject);
begin
lees(arrles);           //activating the LEES procedure
end;

procedure TForm1.btnDisplayClick(Sender: TObject);
begin
vertoon(arrles);       // activating the VERTOON procedure
end;

end.
