Autor Beitrag
Default112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: Fr 30.04.04 01:35 
Also, ich schreibe grad an nem IRC-Bot, da tut sich jetz ein Problem auf: Das Programm wird unübersichtlich.

Ich möchte einige Prozeduren in einer anderen Datei ansiedeln, so dass ich aber so auf sie zugreifen kann, als wären sie einfach an mein Programm drangehängt. Habe ein wenig mit einer zweiten Unit gespielt, aber ich komme nicht zum gewünschten Ergebnis. Ich habe jetzt eine Prozedur, die simples StrinReplace macht. Das sind einige Zeilen, die einfach nur unübersichtlichkeit hervorrufen. Lager ich diese Prozedur in eine zweite Unit aus kann ich zwar von Unit1 darauf zugreifen, Prozeduren aus Unit2 können aber nicht Prozeduren in Unit1 aufrufen. Es muss irgendwie gehen, ich weiss bloss nicht wie :)

Gruß
Default
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 30.04.04 01:43 
Du musst die Unit1 auch in der zweiten Unit aufnehmen. Und dann musst du die Funktionen aus Unit eins noch im Interface Abschnitt oder im public Abschnitt der Klasse "veröffentlichen".
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Fr 30.04.04 03:10 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
unit Unit1;

interface

...

implementation

uses
  Unit2;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Caption := 'Hallo von 1';
  Form2.Show;
end;

end.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
unit Unit2;

interface

...

implementation

uses
  Unit1;

procedure TForm2.Button1Click(Sender: TObject);
begin
  Form1.Caption := 'Hallo von 2';
end;

end.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(
Default112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: Fr 30.04.04 11:23 
Dann bekomm ich nen Fehler: 'Überkreuzender Bezug zweier Units auf Unit1' und 'Überkreuzender Bezug zweier Units auf Unit2'
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Fr 30.04.04 11:30 
Titel: hmm,
Die 'ausgelager' Units schreib ich in die USES Klauses des Interface Teils

Die Main Form schreib ich in den 'ausgelagr' Units in den IMplementation Teil , dadurch vermeidest du das uberkreuzen des Bezugs.

_________________
mfg. Joel
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Fr 30.04.04 12:18 
Klappt schon. Ich hab es gereade getestet.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(
Default112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: Fr 30.04.04 14:25 
Ihr habt mich anscheinend nicht verstanden. Das Beispiel funktioniert. Aber: Ich habe eine Prozedur "Senden" und eine "haxor" (jaja ^^ 24faches Stringreplace). Die Prozedur "haxor" soll ausgelagert werden, ich muss also von Unit1 aus, Prozedur "haxor" in Unit2 aufrufen und von Unit2 aus die Prozedur "Senden" in Unit1. Das bekomme ich nicht hin.
Default112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: Fr 30.04.04 14:33 
Erledigt. Dumm wenn man den Unterschied zwischen Form1 und TForm1 nicht kennt -_-