Autor Beitrag
Iceonly
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Fr 23.12.05 11:55 
Ich habe folgende Deklarationen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
type  TMyTreeData = record
                  IsFile : boolean;
                  TreePath:string[255]; //Enthält: Pfad/zum/Unterbaum/datei.txt
                  RealPath:string[255]; //Enthält bei isFile=true: C:\Projekte\datei.txt
                  end;

type
     TTreefile = file of TMyTreeData


Ich habe einen Treeview, den ich manuell füllen möchte und dann in eine Datei (TTreefile) reinschreiben möchte.
1. Wie könnte man so etwas parsen.
Ich möchte den Treeview über eine Datei füllen (TTreeview).
2. Wie kann ich das parsen?

In den einzelnen Nodes sollen dann die Inhalte aus einem Record (ein Eintrag der Datei) stehen
Das sollte ich aber mit der Data-Eigenschafft hinbekommen.


Kann mir irgendjemand etwas dazu sagen.

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 23.12.05 12:11 
Hallo,

den Baum könntest Du mit
ausblenden Delphi-Quelltext
1:
2:
TreeView.SaveToFile
TreeView.LoadFromFile
speichern und laden.
Den Record erweiterst Du um einen Integer,
in dem der Index des Knotens zu dem der Record gehört,
gespeichert wird.
Dann kannst Du beim späteren Laden die Records wieder zuordnen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Iceonly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Fr 23.12.05 12:32 
user profile iconLannes hat folgendes geschrieben:
Hallo,

den Baum könntest Du mit
ausblenden Delphi-Quelltext
1:
2:
TreeView.SaveToFile
TreeView.LoadFromFile
speichern und laden.
Den Record erweiterst Du um einen Integer,
in dem der Index des Knotens zu dem der Record gehört,
gespeichert wird.
Dann kannst Du beim späteren Laden die Records wieder zuordnen.


Das war auch meine erste Idee, aber leider muss ich das alles in einer Datei speichern so wären es 2:
1. die Textdatei aus savetoFile
2. die Projektdatei
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 23.12.05 13:08 
Hallo,

das könnte dann etwas für Dich sein:
Saving TreeViews to disk

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Iceonly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Fr 23.12.05 13:22 
user profile iconLannes hat folgendes geschrieben:
Hallo,

das könnte dann etwas für Dich sein:
Saving TreeViews to disk

Leider nicht so ganz.


Im Prinzip brauche ich nur 2 rekursive Algorithmen (lesen und schreiben).
Von der Theorie (schreiben-Algorithmus):

schreiben (node)

begin
Schleife beginnt (solange noch weiterer Eintrag vorhanden)
wenn hat child, dann : rufe Funkton "schreiben" neu auf (mit Parameter des Childnodes)


kopiere data
kopiere pfad + aktuellen neuen node
Schleifen ende
end;



In der Praxis bekomme ich das nur nicht hin
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 23.12.05 16:45 
Hallo,

user profile iconIceonly hat folgendes geschrieben:
In der Praxis bekomme ich das nur nicht hin

wie sieht denn Dein Code bis jetzt aus?

Und versuch mal den Baum des TreeView hier darzustellen,
dann kann man besser etwas dazu sagen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 23.12.05 18:28 
user profile iconIceonly hat folgendes geschrieben:
user profile iconLannes hat folgendes geschrieben:
Hallo,

das könnte dann etwas für Dich sein:
Saving TreeViews to disk

Leider nicht so ganz.

das hast du in 13 Minuten festgestellt :gruebel:
Ich halte das für eine sehr gute Lösung.

//Edit: wollte nur editieren :?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Iceonly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Mo 26.12.05 20:53 
Inzwischen geht das speichern/exportieren.

Aber der Import macht mir noch Probleme

Ich habe jetzt eine Textdatei, da steht drin:
Projekt/Test/Test3
Projekt/Test2/Test2_2
Projekt/Test3



Wie kann ich daraus ein Treeview bauen?

So siehts aktuell aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function treeview_open(filename:string);
var tempstring:string;
    node:TTreenode;
    tree:TTreeview;
    f   :Textfile
begin
tree:=TTreeview.create(nil);

assignfile(f,filename);
reset(f);

while not eof(f) do
  begin
  
  end;

closefile(f);


treeview_open:=tree;
end;
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 28.12.05 00:11 
Hallo,

so eventuell?
[url=http://www.delphipraxis.net/topic277,0,asc,0.html]TTreeView-Node-Bäume schnell anlegen
[/url]

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Iceonly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Mi 28.12.05 13:35 
Hat sich schon erledigt.
Aber sowas Ähnliches war es :). Mein Code ist aber Kürzer :wink:
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 28.12.05 13:38 
Hallo,

und wie sieht der aus,
eventuell sucht ja noch jemand so einen Code :wink:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )