Autor Beitrag
cromos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 219


Delphi 7
BeitragVerfasst: Di 30.12.03 19:54 
Hallo,

wie kann ich eine Variable so Defenieren das diese Unit-Weit , in allen Unterprogrammen, verfügbar ist?

Gruss
Cromos
mb
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 185



BeitragVerfasst: Di 30.12.03 20:13 
z.B. so - falls Du das meinst:

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:
unit <UnitName>;

interface

procedure proc1(value1: integer; var value2:integer);
function func1(value: integer): boolean;

implementation

var globalTest: integer;

procedure proc1(value1: integer; var value2:integer);
begin
  value2 := value1 + value2 * globalTest; // Dummy
end;

function func1(value: integer): boolean;
begin
  result := (globalTest mod 2 = 0);
end;

end.


Hat nicht viel Sinn, diese Unit, aber du greifst in beiden Unterroutinen auf die Variable globalTest zu. Wenn auch andere Units, die die <UnitName> einbinden auf die Variable zugreifen können sollen, so musst Du die Variable nicht nach "implementation" sondern schon nach "interface" definieren...

_________________
Gruß,
MB


Zuletzt bearbeitet von mb am Di 30.12.03 20:17, insgesamt 2-mal bearbeitet
cromos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 219


Delphi 7
BeitragVerfasst: Di 30.12.03 20:15 
Danke, das war was ich suchte.

Guten Rutsch

cromos