Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Народ , подскажите плз . Есть в проекте на delphi два файла [D7, XP]


smartleds ©   (2008-01-25 16:35:00) 

Один файл обрабатывает кнопки файл 1, у другого просто процедуры файл 2.
В файле 1 я объявил динамическую матрицу , заполнил ее данными , задал размер, и даже распечатал.
Когда пытаюсь из второго файла обратится к этой матрицы , то данных в ней нет, одни нули , во втором файле матрицу никак не объявлял.
Подскажите что за фигня.


smartleds   (2008-01-25 17:54:00) [1]

Спасибо !


Семеныч   (2008-01-25 17:16:00) [2]

> smartleds   (25.01.08 17:10) [11]

Да. Посмотрите в код файла DPR - увидите.


smartleds   (2008-01-25 17:10:00) [3]

А в чем косяк, у меня что форма создается до того как матрица заполняется?


engine   (2008-01-25 17:07:00) [4]

> [7] smartleds   (25.01.08 17:01)

У тебя формы autocreate.


Семеныч   (2008-01-25 17:05:00) [5]

Обработчик TForm2.OnCreate уберите, а код из него перенесите в обработчик TForm2.OnShow.

А еще лучше - сделайте форму TForm2 неавтосоздаваемой.


Сергей М.   (2008-01-25 17:03:00) [6]


> первая строчка меня убила


А а, говнюк, гляжу на такие строчки и реагирую чучть более бурно.


smartleds   (2008-01-25 17:01:00) [7]

(to clickmaster) Я печатаю на форме два для того чтобы посмотреть что с матрицей, потому что процедура которой я ее скармливаю находится в файле 2 и не работает.


smartleds   (2008-01-25 16:59:00) [8]

Вот код файл 1 Жмем кнопку заполнить матрицу Full matrica потом Print смотрим что получилось , и потом кнопку Show откроется вторая форма и при открытии формы опять матрица выводится и там одни нули, могу сразу проект выслать.
Файл 1
unit palitra_daslight;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, ComCtrls;
const amount_channels=3;
type
 TForm1 = class(TForm)
   Button3: TButton;
   Memo1: TMemo;
   Button5: TButton;
   Button6: TButton;
   procedure FormCreate(Sender: TObject);
   procedure Button3Click(Sender: TObject);
   procedure Button5Click(Sender: TObject);
   procedure Button6Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;
//================- Discription Variables -=======
//var  amount_scene, amount_service_arrays,curtime:integer;
//================- Discription Arrays -==========
var matrica_scene: array of array of byte; // index 1--> stroka (row), index 2-->stolb(colomn)
var
 Form1: TForm1;

implementation

uses show;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
SetLength(matrica_scene,1000,512); // 1-->amount scene ; 3--> amount channels

end;
//-------------- Button Show ------
procedure TForm1.Button3Click(Sender: TObject);
begin
form2.show;
end;
//---------------- Button Full Matrica ------------
procedure TForm1.Button5Click(Sender: TObject);
begin
SetLength(matrica_scene,2,8); // 1-->amount scene ; 3--> amount channels

matrica_scene[0,0] :=181;
matrica_scene[0,1] :=181;
matrica_scene[0,2] :=181;
matrica_scene[0,3] :=101;
matrica_scene[0,4] :=1;
matrica_scene[0,5] :=1;
matrica_scene[0,6] :=1;
matrica_scene[0,7] :=1;
//---------------------
matrica_scene[1,0] :=20;
matrica_scene[1,1] :=20;
matrica_scene[1,2] :=20;
matrica_scene[1,3] :=11;
matrica_scene[1,4] :=1;
matrica_scene[1,5] :=1;
matrica_scene[1,6] :=1;
matrica_scene[1,7] :=1;

end;
//--------------- Button Print ----
procedure TForm1.Button6Click(Sender: TObject);
var i,j:integer;
var st:string;
begin
for i:=0 to 2-1 do
   begin //0
  for j:=0 to 8-1 do
         begin //1
         st:=st+inttostr(matrica_scene[i,j])+' ';
          end; //1
   st:=st+#13;
   end; //0
showmessage(st);
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,0])+'  ');
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,1])+'  ');
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,2])+'  ');
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,0])+'  ');
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,1])+'  ');
form1.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,2])+'  ');

end;
end.
=============================Конец файла 1===============
Файл 2
unit show;

interface

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

type
 TForm2 = class(TForm)
   Memo1: TMemo;
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;
//================- Discription Variables -=======
var timerflag,count,curscene,curindex_delay :integer;
//================- Discription Arrays -==========
//var matrica_scene: array of array of byte; // index 1--> stroka (row), index 2-->stolb(colomn)
var
 Form2: TForm2;

implementation

uses palitra_daslight;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,0])+'  ');
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,1])+'  ');
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[0,2])+'  ');
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,0])+'  ');
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,1])+'  ');
form2.Memo1.Lines.Append('matrica='+inttostr(matrica_scene[1,2])+'  ');
end;

end.


clickmaker   (2008-01-25 16:53:00) [9]


> Так я ее вначале заполняю, печатаю все это в файле 1, потом
> перехожу к форме файла два нажимаю кнопку чтобы распечатать

зачем?
форма 2 печатает как-то иначе?


Семеныч   (2008-01-25 16:44:00) [10]

Чудес не бывает. Давайте код.


smartleds   (2008-01-25 16:41:00) [11]

Так я ее вначале заполняю, печатаю все это в файле 1, потом перехожу к форме файла два нажимаю кнопку чтобы распечатать, а там одни нули.


Семеныч   (2008-01-25 16:39:00) [12]

Если к матрице обратиться, когда она еще не заполнена - что будет?


Palladin   (2008-01-25 16:38:00) [13]

первая строчка меня убила...


Наверх

Титульная страница Поиск, карта сайта Написать письмо