Autor Beitrag
Stoffel1984
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 219

Win NT, Win 2000
D6 Prof
BeitragVerfasst: Mo 11.10.04 15:24 
Hallo,

ist es irgendwie möglich aus einem String einen Konstantennamen zu machen, den ich im Quelltext dann zuweisen kann?

Also z.B.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
CONST1 = 'Hallo';
CONST2 = 'lieber';
CONST3 = 'Programmierer';

for i := 1 to 3 do
  s := s + MachmirneKonstantedraus('CONST'+inttostr(i)); 
ShowMessage(s);



Hoffe Ihr habt verstanden was ich mein...

Danke schonmal,
Stoffel
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mo 11.10.04 15:26 
Nein, das ist so direkt nicht möglich. Warum? Weil im fertig kompilierten Programm nicht mehr die Variablennamen vorhanden sind sondern lediglich Zeiger auf die im Speicher liegenden Zeichenketten.
Bei der Namensgebung könntest du das allerdings auch als array aufbauen!

raziel

_________________
JSXGraph
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 12.10.04 06:41 
Aber du kannst es so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
const
  szStrings: array [1..3] of String = ('Hallo', 'lieber', 'Programmierer');

for i := 1 to 3 do
  s := s + szStrings[i];
ShowMessage(s);

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!