Не считает максимумы, вообще. Помогите пожалуйста найти ошибку.
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, TeEngine, Series, ExtCtrls, TeeProcs, Chart,Math;
type
TForm8 = class(TForm)
Button1: TButton;
Chart1: TChart;
Series1: TLineSeries;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit4: TEdit;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
Var tx:textfile;
i,j,n,k:integer;
x:array of real;
y:array of real;
//meanval:double;
begin
Assignfile(tx,'tab.txt');
Reset(tx);
i:=0;
j:=0;
while not EOF(tx) do
begin
Setlength(x,i+1);
Setlength(y,j+1);
readln(tx,x[i],y[j]);
inc(i);
inc(j);
if (y[j-1]<y[j]) and (y[j]<y[j+1]) then
Edit1.Text:=floattostr(y[j])
else
Showmessage('Нет глобальных максимумов');
if (y[i-1]>y[i]) and (y[i]<y[i+1]) then
Edit2.Text:=floattostr(y[i])
else
Showmessage('Нет глобальных минимумов');
end;
n:=strtoint(edit3.Text);
For i:=0 to n do
Chart1.SeriesList[0].Addxy(x[i],y[i], '', clRed);
end;
//meanval:=Mean(x[i]);
//Closefile(tx);
end.