Autor Beitrag
ShoAn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Di 27.08.02 23:20 
kann mir mal jemand sagen wie ich in einer procedure eine globale variable deklarieren kann?? denn normaler weise kann ich die ja dann nur in der procedure verwenden. ich glaub mit php ging mit: ".. global vartyp: varname.. " aber das is ja ne andere sprache :(
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Di 27.08.02 23:38 
Zitat:
wie ich in einer procedure eine globale variable deklarieren kann??


Kannst du mit Object Pascal nicht.
Wozu soll das gut sein?
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Mi 28.08.02 00:11 
Naja, geht doch, mehr oder weniger zumindest.

Dazu deklarierst du im implementation teil einer unit einfach einen var-Abschnitt und anschließend die variable.

Programmweit zugreifbar kannst du sie machen, wenn du nun noch eine get-function und setprocedure in dieser unit deklarierst und diese unit dann überall dort, wo sie gebrauchst wird, in der uses-clause einfügst.

Gruß
Ken
ShoAn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 28.08.02 00:25 
schade :cry:
zb für:

begin
x:= IntToStr(Edit1.Text);

>> global zahl: array[0..x] fo integer; <<
end;
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mi 28.08.02 10:32 
Hallo,
dafür kannst du Dynamische Arrays verwenden:

ausblenden Quelltext
1:
2:
x:= IntToStr(Edit1.Text);
Setlength(GlobalesArray, x);


Globales Array deklarierst du dir am besten Objecltglobal (also als Eigenscahft deines Objektes) aber ohne Längenenangabe z.B. so:

ausblenden Quelltext
1:
2:
protected
  GlobalesArray : ARRAY OF Integer;


Das ganze solltest du nch mit ein paar Sicherheitsmechanismen versehen (länge nicht ändern wenn es schon eine hat usw.

Gruß
Klabautermann

PS: In Pascal ist es Prinzipiell nicht möglich Variablen im Anweisungsblock zu definieren.
ShoAn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 28.08.02 16:17 
aha! ok danke, werd noch n bisschen rumprobieren :D