Autor Beitrag
cbs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Mo 01.12.08 17:31 
Tach DF

Ist sicher völlig banal, aber ich habe weder über Google noch hier im Forum etwas über mein Problem gefunden.

Ich möchte ganz einfach eine Menge in eine Datei speichern (genauer in einem XML-Tag).

Z.B.:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
  TElement = (elEins, elZwo);
  TElemente = set of TElement;

var
  ele: TElemente;


Ich habe es bisher so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
    for vCntr := Ord(Low(TElement)) to Ord(High(TElement)) do
    begin
      if TElement(vCntr) in ele then
      begin
        // Speichern
      end;
    end;


Geht das auch einfacher? Also ohne alle Möglichen Werte durchzugehen?

Danke schon mal!

mfg

cbs
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 01.12.08 20:15 
Hi :)

Mach doch einfach eine typisierte Datei daraus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
type
  TMySet = set of TElement;
  TMySetData = file of TMySet;

{..}

procedure SaveSets(aSets: Array of TMySet; aPath: String);  //Speichert alle Sets im Array
var
  i: Integer;
  f: TMySetData;
begin
  AssignFile(aPath, f);
  ReWrite(f);
  for i := 0 to High(aSets) do
    WriteLn(f, aSets[i]);
  CloseFile(f);
end;


mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Mo 01.12.08 22:18 
Oder beschäftige dich etwas mit den Möglichkeiten aus Types.pas. Damit wird auch das Streaming der Formulare (*.dfm) erledigt.
cbs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Di 02.12.08 10:23 
@Hidden:

Die Möglichkeit bringt mir nichts, da ich die Menge ja in ein XML-Tag speichern möchte.

@Bernhard Geyer:

Ich habe mal in die types.pas reingeschaut, aber nichts relevantes gefunden. Was meinst du denn genau?