Autor Beitrag
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 20.01.04 19:33 
Hi,
wie ich meine eigene Procedure erstelle weis ich ja.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure meineProc;
var zahl1,zahl2,zahl3:integer;
begin
zahl1:= 1;
zahl2:= 5;
zahl3:= zahl1 + zahl2 ;
showmessage('Das Ergebnis ist: '+inttostr(zahl3));
end;

Doch nun will ich von einer anderen Form aus diese Procedure aufrufen und die Werte der Zahlen ändern.

Wie mache ich das am einfachsten?

thx hibbert

Moderiert von user profile iconDeCodeGuru: Topic verschoben

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 20.01.04 19:39 
Hallo!

Die Prozedur muss im Interface-Teil der Unit, in der sie steht, (nennen wir mal "Unit1") eingetragen sein.

Dann kannst Du die Prozedur aus einer "Unit2" durch den Aufruf "Unit1.ProzedurName" aufrufen, falls Unit1 in der Uses-Klausel von Unit2 steht.

MfG
Peter

P.S.: Falls der ProzedurName in den von Unit2 aus erreichbaren Units einzigartig ist, kann das "Unit1." auch weggelassen werden.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 20.01.04 19:58 
ok,
das habe ich mir schon fast gedacht:
Ich weiß nämlich nicht, wie ich die Procedure dort eintragen muss und wie ich die Variabeln dieser Procedure ändern kann. :oops:

kannst du mir das vielleicht mal erklären *liebkuck*

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 20.01.04 20:15 
Habe mein System neu drauf gemacht, deswegen noch kein Delphi drauf. Aber versuchen kann ich es ja.

Also, Unit1:
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:
36:
37:
unit uni1;

interface

uses ...;

Type TForm1 = Class(TForm1)
   {... Komponenten ...}
   {... Methoden ...}
  private
  public
     procedure meineProz1;
  end;

procedure meineProz2;
procedure meineProz3;

Var
  Form1 : TForm1;

implementation


procedure TForm1.meineProz1;
begin
  {mach was}
end;

procedure meineProz2;
begin
  {mach was anderes}
end;

procedure meineProz3;
begin
  {mach noch was}
end;


So, und nun Unit2:
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:
26:
27:
28:
29:
30:
unit unit2;

interface

uses ..., unit1;

Type TForm2 = Class(TForm2)
   {... Komponenten ...}
   {... Methoden ...}
  private
  public
  end;

procedure meineProz2;

Var
  Form2 : TForm2;

implementation

//uses unit1;
(*Hier kann man auch eine uses-Klausel benutzen. Aber nur, wenn man die Units im Interface-Teil noch nicht braucht. Und oben darf die entsprechende Unit dann nicht mehr stehen*)


procedure meineProz2;
begin
  unit1.meineProz2;
  meineProz3;
  form1.meineProz1;
end;


So sollte es funktionieren.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 20.01.04 20:31 
Ok,
doch da gibt es ein kleines Problem:
Meine Procedure hat einen anderen Namen.

...

Halt, war nur ein Scherz :lol:
es funzt so wie ich das haben wollte.

Danke !!

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 20.01.04 20:42 
Zitat:
doch da gibt es ein kleines Problem:
Meine Procedure hat einen anderen Namen.
:lol: :lol:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 20.01.04 20:45 
ist ja ok, ich gebe es zu, war ein "toller" Witz.

Aber nun mal im ernst, meine Procedure hat(te) wirklich einen anderen Namen !! :roll:

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 20.01.04 20:51 
Ich bin zu sehr Individualist, als dass ich die Prozedurnamen anderer Leute verwenden könnte. ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Di 20.01.04 21:15 
... :wink:

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej