Добрый день!
Проблема в следующем.После компиляции программы(компилятор ошибок не выдал), при нажатии на кнопку решения выдается следующая ошибка: "Acces violation at adress 0045949В in Module`название модуля`write of adress 00000004" Код программмки
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Solve, KoshiTask ;
type
TForm1 = class(TForm)
EditN: TEdit;
Button1: TButton;
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FTask: TKoshiTask;
solve:Tsolve;
procedure EilerSolve(Task: TKoshiTask; Solve: TSolve);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.EilerSolve(Task: TKoshiTask; Solve: TSolve);
var
I: Integer;
h:real;
begin
Solve.N := Task.N;
Solve.X1[0] :=Task.X10;
Solve.X2[0]:= Task.X20;
Solve.Y1[0]:=Task.Y10;//tASK. УСТАНОВИТЬ НАЧАЛЬНЫЕ ЗНАЧЕНИЯ
Solve.Y2[0] :=Task.Y20;
h:=(Task.t1-Task.t)/Solve.N;
for I := 1 to Task.N do
begin
Solve.X1[I]:=Solve.X1[I - 1]+h*solve.Y1[I - 1];
Solve.Y1[I]:=Solve.Y1[I - 1]+h*(-task.R11*solve.X1[I - 1]-Task.R12*Solve.X2[I - 1])/Task.Inr;
Solve.X2[I]:=Solve.X2[I - 1]+h*solve.Y2[I - 1];
Solve.Y2[I]:=Solve.Y2[I - 1]+h*(-task.R21*solve.X1[I - 1]-Task.R22*Solve.X2[I - 1])/Task.m;
task.t:=task.t+h;
ListBox1.Items.Add(FormatFloat('x1(0.###) = ',task.t)+FormatFloat('(0.###) =',Solve.X1[I]));
ListBox2.Items.Add(FormatFloat('x2(0.###) = ',task.t)+FormatFloat('(0.###) =',Solve.X2[I]));
// шаг умноженный на занчение функции в i-1 узле;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FTask.N := StrToInt(self.EditN.Text);
FTask.R11:=StrToInt(self.Edit1.Text);
FTask.R12:=StrToInt(self.Edit2.Text);
FTask.R21:=StrToInt(self.Edit3.Text);
FTask.R22:=StrToInt(self.Edit4.Text);
FTask.t:=StrToInt(self.Edit5.Text);
FTask.t1:=StrToInt(self.Edit6.Text);
FTask.Inr:=StrToInt(self.Edit7.Text);
FTask.m:=StrToInt(self.Edit8.Text);
FTask.X10:=StrToInt(self.Edit9.Text);
FTask.X20:=StrToInt(self.Edit10.Text);
FTask.Y10:=StrToInt(self.Edit11.Text);
FTask.Y20:=StrToInt(self.Edit12.Text);
EilerSolve (FTask,Solve);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FTask := TKoshiTask.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FTask.Destroy;
end;
end.
unit KoshiTask;
interface
type
TKoshiTask = class(TObject)
private
FR11: Double; // Элементы матрицы жесткости
FR12: Double;
FR21: Double;
FR22: Double;
FN: Integer; // Количество шагов
Ft: Double; //начальное время
Ft1: Double; //конечное время
FInr: Double; //момент инерции
Fm: Double; //масса
FX10: Double;// начальные условия
FX20: Double;
FY10: Double;
FY20: Double;
public
property N: Integer read FN write FN;
property R11: Double read FR11 write FR11;
property R12: Double read FR12 write FR12;
property R21: Double read FR21 write FR21;
property R22: Double read FR22 write FR22;
property t: Double read Ft write Ft;
property t1: Double read Ft1 write Ft1;
property Inr: Double read FInr write FInr;
property m: Double read Fm write Fm;
property X10: Double read FX10 write FX10;
property X20: Double read FX20 write FX20;
property Y10: Double read FY10 write FY10;
property Y20: Double read FY20 write FY20;
procedure CopyFrom(Source: TKoshiTask);
end;
implementation
{ TKoshiTask }
procedure TKoshiTask.CopyFrom(Source: TKoshiTask);
begin
self.FR11 := Source.FR11;
self.FR12 := Source.FR12;
self.FR21 := Source.FR21;
self.FR22 := Source.FR22;
self.t := Source.t;
self.t1 := Source.t1;
self.Inr := Source.Inr;
self.m := Source.m;
self.X10 := Source.X10;
self.X20 := Source.X20;
self.Y10 := Source.Y10;
self.Y20 := Source.Y20;
end;
end.
unit Solve;
interface
type
TSolve = class(TObject)
private
FN: Integer;
FX1: array of Double;
FX2: array of Double;
FY1: array of Double;
FY2: array of Double;
procedure SetN(N: Integer);
procedure SetX1(I: Integer; X: Double);
function GetX1(I: Integer): Double;
procedure SetX2(I: Integer; X: Double);
function GetX2(I: Integer): Double;
procedure SetY1(I: Integer; X: Double);
function GetY1(I: Integer): Double;
procedure SetY2(I: Integer; X: Double);
function GetY2(I: Integer): Double;
public
property N: Integer read FN write SetN;
property X1[I: Integer]: Double read GetX1 write SetX1;
property X2[I: Integer]: Double read GetX2 write SetX2;
property Y1[I: Integer]: Double read GetY1 write SetY1;
property Y2[I: Integer]: Double read GetY2 write SetY2;
end;
implementation
{ TSolve }
procedure TSolve.SetN(N: Integer);
begin
FN := N;
SetLength(FX1, N + 1);
SetLength(FX2, N + 1);
SetLength(FY1, N + 1);
SetLength(FY2, N + 1);
end;
function TSolve.GetX1(I: Integer): Double;
begin
Result := FX1[I];
end;
procedure TSolve.SetX1(I: Integer; X: Double);
begin
FX1[I] := X;
end;
function TSolve.GetX2(I: Integer): Double;
begin
Result := FX2[I];
end;
procedure TSolve.SetX2(I: Integer; X: Double);
begin
FX2[I] := X;
end;
function TSolve.GetY1(I: Integer): Double;
begin
Result := FY1[I];
end;
procedure TSolve.SetY1(I: Integer; X: Double);
begin
FY1[I] := X;
end;
function TSolve.GetY2(I: Integer): Double;
begin
Result := FY2[I];
end;
procedure TSolve.SetY2(I: Integer; X: Double);
begin
FY2[I] := X;
end;
end.
В чем тут ошибка? Заранее благодарен за ответы.