![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
вот этот код заканчивается ошибкой:
Код:
unit iRobot_MainUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
const
x = 50;
y = 50;
dlinaPlat = 40;
vysotaPlat = 20;
type
TPlat = class
x1,y1:integer;
t:real;
constructor Create;
procedure Period;
end;
TForm1 = class(TForm)
Panel1: TPanel;
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Plat: TPlat;
implementation
{$R *.dfm}
constructor TPlat.Create;
begin
x1:=x;
y1:=y;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Plat.Period;
end;
procedure TPlat.Period;
begin
t:=t+(Form1.Timer1.Interval)/1000;
end;
end.вывод ошибки: Код:
--------------------------- Debugger Exception Notification --------------------------- Project xxxxx raised exception class EAccessViolation with message 'Access violation at address 00472DB8 in module 'xxxxx'. Read of address 00000010'. Process stopped. Use Step or Run to continue. --------------------------- OK Help --------------------------- и ссылается на строку t:=t+(Form1.Timer1.Interval)/1000; помогите, в чем причина, весь день уже бьюсь, хотя брал часть кода из двух разных программ и там работает, вроде все перепроверил - совпадает.. Последний раз редактировалось s2h, 20.05.2009 в 16:24. |
|
#2
|
|||
|
|||
|
Вы в обработчике события OnTimer изменяете атрибут несуществующего объекта, так как конструктор для Plat вы нигде не вызываете.
|
|
#3
|
|||
|
|||
|
хм, а как его вызвать тогда?
там же уже стоит constructor Create; и constructor TPlat.Create; хотя... сейчас проверю) спасибо) точно! забыл прописать procedure TForm1.FormCreate(Sender: TObject); begin Plat:=TPlat.Create; end; блин, такая фигня и столько времени потрачено, эх)) Последний раз редактировалось s2h, 20.05.2009 в 17:09. |