Autor Beitrag
Redrah
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Sa 09.09.06 17:55 
Hi Leutz,
ich hab folgendes Programm
ich hab in meinen Hauptprogramm ein globales 2dim. Array vom Typ Integer deklariert und gefüllt.
Nun möchte ich aber gerne in einer anderen Unit damit arbeiten. Diese Unit ist natürlich im Hauptprogramm initialisiert.
Meine Frage ist, wie kann ich auf das Array aus dem Hauptprogramm in einer anderen Unit zugreifen ?
Vielen Dank für eure Hilfe.

MFG Daniel
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 09.09.06 17:56 
schonmal versucht das Array in den Public bereich der Unit zu schreiben?

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 09.09.06 17:58 
user profile iconRedrah hat folgendes geschrieben:
Diese Unit ist natürlich im Hauptprogramm initialisiert.

Wie initialisiert?
user profile iconRedrah hat folgendes geschrieben:
wie kann ich auf das Array aus dem Hauptprogramm in einer anderen Unit zugreifen ?

In der zweiten Unit den Namen der Hauptunit unter uses aufnehmen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Sa 09.09.06 18:06 
Hi,
naja mit uses initialisiert.

Wenn ich uses Hauptprogramm schreibe in die Unit, dann klappt das trotzdem immer noch nicht

Soll ich das Array aus dem Hauptprogramm nochmal in den public Bereich von der unit schreiben oder wie?
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 09.09.06 18:07 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconRedrah hat folgendes geschrieben:
Diese Unit ist natürlich im Hauptprogramm initialisiert.

Wie initialisiert?

ich denke mal in die uses klausel aufgenommen...

user profile iconMarco D. hat folgendes geschrieben:
user profile iconRedrah hat folgendes geschrieben:
wie kann ich auf das Array aus dem Hauptprogramm in einer anderen Unit zugreifen ?

In der zweiten Unit den Namen der Hauptunit unter uses aufnehmen.


eigentlich meinte ich das, nur habe ich unit mit hauptprogramm verwechselt :oops:

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Sa 09.09.06 18:10 
Okay uses habe ich gemacht.
Ich kann es trotzdem immer noch nicht ausführen.
Was habe ich vergessen?
Vielen Dank
Daniel
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 09.09.06 18:23 
Fehlermeldung?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
hui1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Sa 09.09.06 18:27 
user profile iconhibbert hat folgendes geschrieben:
schonmal versucht das Array in den Public bereich der Unit zu schreiben?


Vielleicht hast du das Vergessen.

Hier ien Beispiel:

Hauptunit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
    myArray: Array[0..10] of String; //In den Public-Bereich einfügen!!
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.


Zweite Unit:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
var
  n: Integer;
begin
  For n:=0 to 10 do
    Form1.myArray[n]:='String: '+IntToStr(n);
end;

end.
Redrah Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Win XP
D6, Turbo Delphi
BeitragVerfasst: Sa 09.09.06 18:40 
Vielen Dank für eure Hilfe.
Besonderen Dank an hui1991 für die sehr ausführliche Hilfe.