Autor Beitrag
Der Jan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win2k prof, WinXP prof, Linux
D6 Prof, BCB4 Std, BCB6 Ent, BDS 2006 Ent
BeitragVerfasst: Do 10.11.05 14:41 
Hallo,

gibt es in Delphi ein Äquivalent zum #define symbol wert in C/C++ ?
Ich meine nicht {$define symbol}

_________________
Gruß, Jan
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Do 10.11.05 14:43 
Hallo! :wink2:

Nein, so weit ich weiß kannst du ein Symbol definieren oder nicht. Aber ein Symbol auch einen Wert geben geht nicht.

Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 10.11.05 14:47 
const Schlüssel = Wert;
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Do 10.11.05 14:51 
Die Konstanten werden aber dann in die Anwendung mit reinkompiliert und das will er glaube ich nicht. Sondern nur eine Art Konstante die nur der Kompiler wärend der Zeit des kompilierens kennt - die Anwendung aber nicht.

Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 10.11.05 14:56 
Also gibt man die Konstante untypisiert an, dann wird überall da, wo die Konstante verwendet wird, der Wert der Konstanten eingesetzt. Bei typisierten Konstanten merkt er sich den Wert nur einmal und verweist dann auf diesen.
Der Jan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win2k prof, WinXP prof, Linux
D6 Prof, BCB4 Std, BCB6 Ent, BDS 2006 Ent
BeitragVerfasst: Do 10.11.05 14:58 
Na das nenn ich schnell :D

user profile iconSpaceguide hat folgendes geschrieben:
const Schlüssel = Wert;


Das ist ist auch nicht was ich meine...

Das Symbol soll bei seinem Auftauchen im Quellcode ersetzt werden

Also
ausblenden Delphi-Quelltext
1:
2:
{$define wert blabla}   //gesetz dem Fall, es ginge so
s:="wert";


wird zu
ausblenden Delphi-Quelltext
1:
s:="blabla";					


Ist vielleicht kein gutes Beispiel, aber das geht mit dem const leider nich...
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Do 10.11.05 14:59 
Ja, genau. Aber das ändert meine Aussage oben auch nicht. ;-)

Er will - wenn ich es richtig verstanden habe (ich kann C++ leider nicht) - keine Konstanten definieren.

Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 10.11.05 15:05 
Einen Präprozessor im C-Stil gibt es bei Delphi nicht. Wozu brauchst du das denn? Mittlerweile wird ja die Verwendung von #define anstelle von const auch unter C/C++ als schlechter Stil angesehen.

Stefan
Der Jan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win2k prof, WinXP prof, Linux
D6 Prof, BCB4 Std, BCB6 Ent, BDS 2006 Ent
BeitragVerfasst: Do 10.11.05 15:34 
Schade, schade...

Was ich damit will? Genau das oben beschriebene und von Martin1966 erläuterte.. :)

Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
const c = 1;
//...
var i: int;
    s: string;
//...
i := c;
s := c; //Fehler string <-> integer, wäre mit Defines nicht passiert...


Naja, kann man wohl nix machen .... :?

_________________
Gruß, Jan
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 10.11.05 16:18 
Das geht in C aber auch nicht.
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Do 10.11.05 17:22 
Das von dir erwünschte Verhalten entspricht nicht dem Präprozessor, sondern Suchen/Ersetzen ;)

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind