Autor Beitrag
Deerfield
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35


Delphi XE Pro
BeitragVerfasst: Do 23.10.03 12:03 
Hallo,

kennt jemand einen Möglichkeit, die analog der Funktion LoadStr() mit Strings ist, allerdings für Konstanten?

MfG
Deerfield
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 25.10.03 11:12 
Hallo,

wie jetzt? Ressourcen-Strings sind doch Konstanten, oder...?

Willst du so was implementieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
const
  S1 = 'Hello world';

{ ... }

var
  S: string;
begin
  S := LoadStringConst('S1');

Wenn du so was meinst - das geht nicht.

Oder meinst du was ganz anderes, und ich verstehe dich nur falsch?

_________________
Life is a bad adventure, but the graphic is really good!
Deerfield Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35


Delphi XE Pro
BeitragVerfasst: Mo 27.10.03 16:02 
Naja das ganze sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
const
  SIZE = $35;
  texte : Array[0..SIZE] of ShortString = (
{00}'OK',
       'Abbrechen',
       'Text 1',
       'Text 2',
       'Text 3',
{05}'Text 4',
...

);


Die Texte will ich aber nun aus einer externen Ressourcen-Datei laden...
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 27.10.03 20:13 
Hallo,

also, du willst Strings inne Ressource schreiben, und dann zur Laufzeit auslesen, ja? Nun denn, derm Manne kann geholfen werden. Lege eine RC an:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
STRINGTABLE
BEGIN
 0, "Hallo!"
 1, "Wie heißen Sie?"
 2, "Gute Tag, %s!"
 3, "Drücken Sie [ESC] um zu beenden!"
END

Nun kompiliere das Ding mit Brcc32.exe und binde es mit $R in's Projekt ein.

Und dann kannst du die Strings zur Laufzeit mit LoadString() laden Syntax selbsterklärend.

Fragen...?[/delphi]

_________________
Life is a bad adventure, but the graphic is really good!
Deerfield Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35


Delphi XE Pro
BeitragVerfasst: Di 28.10.03 07:10 
Das ganze muss ein Array bleiben. Ressourcen Files benutze ich schon. Da er das Array aber als Konstantenausdruck interpretiert, klappt LoadStr() leider nicht, keine Ahnung warum.
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Di 28.10.03 15:52 
Hallo,

wo ist das Problem? Du kannst das doch als Array laden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
  I: Integer;
  Strings: array of string;
  Str: array [0..255] of Char;
begin
  I := 0;
  SetLength(Strings, 0);
  while (LoadString(HInstance, I, @Str[0], SizeOf(String)) <> 0) do
  begin
    SetLength(Strings, Length(Strings) + 1);
    Strings[High(Strings)] := string(Str);
    Inc(I);
  end;
end;


So müsste es gehen...

_________________
Life is a bad adventure, but the graphic is really good!