Autor Beitrag
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Sa 11.06.05 19:03 
Hoff mal das hier die richtige Sparte für mein Problem ist.

So: Ich habe ein paar Funktionen und Prozeduren die ich immer wieder in verschiedenen Programmen brauche. Ich will das nicht immer mit Copy&Paste machen. Man kann die doch irgendwie in eine eigene Unit auslagern oder? Wie mach ich das und wie kann ich dann drauf zugreifen?

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Sa 11.06.05 19:06 
Die Unit ins Delphi-Library-Verzeichnis und dann die Unit oben bei uses dazuschreiben. ;) Müsste gehen.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Sa 11.06.05 19:12 
Jawoll... Funktioniert... ;)

Du schreibst z.B. folgende Unit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
unit meinTest;

interface

procedure lineout(aString: String);

implementation

procedure lineout(aString: String);
begin
writeln(aString);
end;

end.


Speicherst sie z.B. unter C:\Programme\Borland\Delphi 7 PE\Lib\meinTest.pas ab.

Dann kannst du sie in jedem anderen Programm auch wieder verwenden. Z.B. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
program TestIt;

{$APPTYPE CONSOLE}

uses
SysUtils, meinTest;

begin
lineout('bla');
readln;
end.

;)
Calyptus Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: So 12.06.05 12:39 
Danke... Es tut soweit.
Ich hab jetzt aber noch eine Frage. Ich will von der 2. Unit aus etwas in ein Edit Feld eintragen, aber das geht irgendwie nicht... wie mach ich das?

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 12.06.05 12:47 
Da musst du dann die andere Unit (die mit dem Edit) mit unter uses einbinden. ;) Dann rufst du das Edit-Feld so auf:

ausblenden Delphi-Quelltext
1:
MeineUnitMitDemEdit.Edit1.Text := 'neuer Text';					


;)
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 12.06.05 12:48 
user profile iconCalyptus hat folgendes geschrieben:
Ich will von der 2. Unit aus etwas in ein Edit Feld eintragen, aber das geht irgendwie nicht... wie mach ich das?

auf gehts in die RateRunde ...

ich rate: du schreibst die Form nicht davor (z.B. form1.editFeld.text:=''.), die entsprechende Formunit mit in den implemention Teil aufnehmen (macht Delphi auch allein beim compilieren). Obwohl das dem widerspricht, was du oben geschrieben hast. So wirst du sicher Probleme haben, die Unit über mehrere Projekte immer wieder zu verwenden. Keine Ahnung, was du vorhast, aber du könntest z.B. deine Prozeduren so anpassen, das du das Edit-Feld immer als Paramter übergibst, somit bist du unabhänig und allgemein.

In den Delphi-Ordner würde ich die Units nicht speichern. Du kannst die Unit irgendwo ablegen und die Suchpfade entsprechend einstellen oder bindest sie immer mit ins Projekt ein.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 12.06.05 12:51 
user profile iconWeBsPaCe hat folgendes geschrieben:
Da musst du dann die andere Unit (die mit dem Edit) mit unter uses einbinden. ;) Dann rufst du das Edit-Feld so auf:
ausblenden Delphi-Quelltext
1:
MeineUnitMitDemEdit.Edit1.Text := 'neuer Text';					

;)


Mhmm... :oops: Da ist n Fehler drin... Sorry... So muss der Code aussehen:
ausblenden Delphi-Quelltext
1:
MeineUnitMitDemEdit.Form1.Edit1.Text := 'neuer Text';					
Calyptus Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: So 12.06.05 13:17 
Danke so gehts :-)

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 12.06.05 13:25 
user profile iconCalyptus hat folgendes geschrieben:
Danke so gehts :-)

Kein Problem. ;)