Autor Beitrag
nobody123
Hält's aus hier
Beiträge: 2



BeitragVerfasst: So 02.03.03 19:08 
Hi ich habe ein Problem, ich hoffe es kann mir jemand helfen!
Ich habe mehrer Units. Wo muss ich die Variablen definieren wenn ich sie in allen Units benutzen möchte :?:
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 19:13 
in den public deklarations
nobody123 Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: So 02.03.03 19:38 
Titel: ka
Kannst du mir zeigen wie das geht was ich da reinschreiben solll bitte
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 19:43 
ok


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }         <<DAREIN!!!
    s: string;   //z.B.
  end;

var
  Form1: TForm1;

implementation
...
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 02.03.03 21:54 
Fast. Wenn du das in den Public Bereich von Form1 machst, dann muß du auch in den andern Units "Form1" vorsetzen.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }         
  end;

var                            <<DAREIN IST BESSER!!!
  Form1: TForm1;
  s: string;   //z.B.

implementation
...
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 21:56 
:oops: hast ja recht :wink:
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 04.03.03 15:15 
was haltet ihr von einer unit 'globals', welche die paar wenigen,
wirklich notwendigen, globalen variablen beinhaltet?
diese wird dann in die betreffenden units eingebunden...

irgendwie sieht mir so eine konstruktion komisch aus:

ausblenden Quelltext
1:
2:
3:
4:
unit unit1;

interface 
uses unit2;


ausblenden Quelltext
1:
2:
3:
4:
unit unit2;

interface
uses unit1;


oder erscheint nur mir das wie eine katze, die sich in den eigenen schwanz beißt? :wink:

mfg, stefan