Autor Beitrag
Anfänger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP
D3 Prof
BeitragVerfasst: So 16.05.04 18:21 
Ich habe eine Funktion oder Prozedur, die ich in mehreren Programmen verwenden möchte.
Dazu dachte ich, daran eine neue Unit zu erstellen.
Nun habe ich gekuckt, wie das geht und bin nun zu diesem Quelltext gekommen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
unit Delay;

interface
  procedure Delay(t: DWord);

uses
  Windows, Forms;

implementation

procedure Delay(t: DWord);
var
  Tick:DWord;
begin
  Tick:=GetTickCount;
  repeat
    Application.ProcessMessages;
  until ((GetTickCount - Tick) > t);
end;

end.

(Ist der Code richtig?)

Ich habe das als Delay.pas gespeichert und möchte diese Unit nun verwenden.

Jetzt kommt das Problem:
Wenn ich diese Unit mit nem Programm mit uses aufrufen will muss es doch ne *.dcu sein! :?:
Ist es eigendlich wichtig, wo sich die Datei befindet? :?:
Muss man die Unit irgendie wie ein neues Objekt installieren? :?:
Brueggendiek
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 304

Win 98, Win98SE, Win XP Home
D5 Std
BeitragVerfasst: So 16.05.04 21:20 
Hallo!

1.: Das ist nicht richtig so - Unit und Prozedur dürfen nicht gleich heißen!

2.: Wenn Du eine Unit einfügst und die DCU existiert nicht, compiliert Delphi die PAS-Datei automatisch. Das gilt auch, wenn Du den Source veränderst.
Es ist nur nötig, daß sich die PAS-Datei im erreichbaren Pfaden befindet - also im Projektverzeichnis oder in den Suchpfaden.

Gruß

Dietmar Brüggendiek
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: So 16.05.04 22:59 
Ein Tip: Bei Units immer ein kleines "u" vorstellen, z.B. "uDelay". Dann kommt der Name nicht in den Weg.

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

WinXP
D3 Prof
BeitragVerfasst: So 16.05.04 23:02 
Ich habe nun den Namen der Pas-Datei geändert.
Ich hatte vor, die Unit wie die Unit Forms und Dialogs von jedem Programm aus zugriffsfähig zu machen. Auch, wenn es einen anderen Pfad hat.

In diesem Fall will er immer ne dcu.


Übrigens in dem Code war ein Fehler. Den Uses-Teil habe ich nun vor die Proceduren-deklaration gepackt.
Ich fand es allerdings nicht nötig ihn nochmal zu posten.
Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP
D3 Prof
BeitragVerfasst: So 16.05.04 23:12 
Es klappt :!: :?:

Ich habe irgendwie ne dcu-Datei bekommen :lol:
Diese habe ich in die Libary von Delphi kopiert und es hat geklappt.

Mein einzig kleines Problem ist, das ich nicht weiß wie es zu der dcu kahm.
kann mir das jemand erklären?
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Mo 17.05.04 10:28 
Brueggendieck hat folgendes geschrieben:
2.: Wenn Du eine Unit einfügst und die DCU existiert nicht, compiliert Delphi die PAS-Datei automatisch. Das gilt auch, wenn Du den Source veränderst.


Wenn man jetzt nochmal erwähnt das .dcu - Dateien kompilierte .pas - Dateien sind (Delphi compiled unit) dann sollte Deine Frage beantwortet sein. :wink:

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!
Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP
D3 Prof
BeitragVerfasst: Mo 17.05.04 13:34 
OK - Danke für die Hilfe :idea: