Autor Beitrag
Luzifer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 17:52 
hi leutz, ich hab nur ne kurze dumme frage: wie kann ich die procedure die in unit1 steht und dort auch wunderbar funktioniert, von unit2 aus aufrufen?
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 19.04.05 18:08 
einfach in den uses von unit2 unit1 aufnehmen und dort, wo die funktion in unit2 aufgerufen werden soll, schreiben:

ausblenden Delphi-Quelltext
1:
form1.rufmichauf;					
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 18:10 
hmm das funktioniert bei mir nicht......
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Di 19.04.05 18:11 
Wieso?
Welcher Feheler?
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:14 
du must die Prozedur auch noch in Public eintragen, da sonst die Prozedur auf die Unit beschränkt ist. Es reicht eigentlich, wenn die Prozedur unter interface und über implementation steht, dann kannst du die auch verwenden.
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 18:14 
undefinierter bezeichner "rufmichauf"
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.04.05 18:15 
*Glaskugel reib*.....*Quellcode such*...

Edit: Heisst deine Funktion wirklich "rufmichauf" :?:

_________________
We are, we were and will not be.


Zuletzt bearbeitet von Gausi am Di 19.04.05 18:16, insgesamt 1-mal bearbeitet
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 18:15 
user profile iconHeiko hat folgendes geschrieben:
du must die Prozedur auch noch in Public eintragen, da sonst die Prozedur auf die Unit beschränkt ist. Es reicht eigentlich, wenn die Prozedur unter interface und über implementation steht, dann kannst du die auch verwenden.


wie funktioniert das genau? die procedure in public eintrage? also vom syntax her
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:17 
@Gausi: Dies ist wirklich ein sinnvoller Beitrag. Ist fraglich ob Luzifer das auch auf anhieb vertsteht, dass er erstmal im Forum suchen soll :wink: .

@Luzifer: Das ist aber nicht böse gemeint. Ich glaub aber es gibt schon genug zu diesem Thema in diesem Forum.
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Di 19.04.05 18:18 
Musst du eigentlich nicht (zumindest in D 2005), einfach ganz normal da definieren wo die anderen Proc, und Fuk. dekl. sind.
Muetze1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 346



BeitragVerfasst: Di 19.04.05 18:18 
Moin!

Oben im Teil unter "interface" den Procedurekopf nochmal hinschreiben mit den Parametern. Prozedurekopf = alles ohne den Begin/End Teil...

MfG
Muetze1
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:19 
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  procedure TForm1.sagichnicht;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  // procedure sagichnicht; //2. Variante
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.sagichnicht;
begin

end;

end.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.04.05 18:21 
Oder so:
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:
unit Unit1;

interface

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

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

  procedure sagichnicht; //3. Variante

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure sagichnicht;
begin

end;

end.

_________________
We are, we were and will not be.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:26 
Das ist die Variante wo ich sagte, dass es reicht wenn der Prozedurenkopf im interface..implementation steht. Ich finde die aber ungüstig, von der Übersicht her, da es übersichtliger ist, wenn man die Prozedur, aus einer anderen Unit, mit dem Namen der Unit davor aufruft.
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 18:27 
ihr werdet lachen, aber es funktioniert (bei mir immer noch nicht), wahrscheinlich weil ich zu blöd bin.... wenn das so mache, wie oben beschrieben und dann in unit2 versuche die procedur auf zu rufen, sagt er mir immer "undefinierter bezeichner"

diese möglichkeiten hab ich schon probiert:
ausblenden Delphi-Quelltext
1:
2:
3:
unit1.sagichnicht;
form1.sagichnicht;
sagichnicht;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.04.05 18:29 
@Heiko: Ist aber dann günstiger, wenn die Prozedur mit der Form eigentlich nichts zu tun hat.

@luzifer: Hast du denn die Unit1 in Unit2 bei "Uses " eingetragen?

_________________
We are, we were and will not be.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:29 
In der 2. Unit trägst du dann bei uses z.B. Unit1 ein. In der Unit2 ruftst du die Prozedur aus Unit 1 folgendermaßen auf:

ausblenden Delphi-Quelltext
1:
Form1.sagichnicht					
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:31 
@Gausi: Wann kommt es schon mal vor, dass eine Prozedur überhaupt nix mit der Unit zu tun hat? Wenn es der Fall ist, schreibt man die Prozedur normalerweise auch nicht dorthin.
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Di 19.04.05 18:31 
ok jetzt sagt er "Ungenügende Forward- oder External-Deklaration"
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Di 19.04.05 18:34 
Hast du deien Variablennamen mit definiert?,
Hast du in der Dek, das FormX. weggelassen?