Autor Beitrag
Xadron
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Sa 07.04.07 08:33 
Hallo,

Ich wollte nun einmal den Inhalt von den 3 edit*.text in eine Datei abspeichern.
Wenn ich die Datei mit dem Editor öffne, soll es das so aussehen:

ausblenden Quelltext
1:
2:
3:
ich bin der text
ich bin der andrere text
und ich bin auch ein text


Muss diese Datei dann eine txt Datei sein oder kann es auch eine andere sein?
Und wie mache ich, dass der inhalt in die Datei gespeichert wird?

Danke schonmal im Vorraus


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Sa 07.04.2007 um 17:02

_________________
|x-32:88x+39-3|+3:21=47-4x
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 07.04.07 08:44 
Der einfachste Weg dürfte der über eine Stringlist sein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var aStringlist: TStringlist;
//..
aStringlist := TStringlist.Create;
aStringlist.Add(Edit1.Text);
aStringlist.Add(Edit2.Text);
aStringlist.Add(Edit3.Text);
aStringlist.SaveToFile('c:\MeineDatei.txt');
aStringlist.Free;

Wie die Datei heißt, ist dabei vollkomen egal. Du kannst sie auch "Urlaubsbild.jpg" nennen, was aber relativ wenig Sinn macht.

_________________
We are, we were and will not be.
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Sa 07.04.07 15:39 
Danke erstmal.

Wie kann ich die abgespeicherten Texte wieder auslesen und in die entsprechenden Edit.text schreiben?

_________________
|x-32:88x+39-3|+3:21=47-4x
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 07.04.07 15:42 
Auch wieder über die Stringlist - nur andersrum. Zuerst laden, und dann die einzelnen Strings auf die Edits verteilen.

_________________
We are, we were and will not be.
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Sa 07.04.07 15:57 
Hm ja.

Unter laden könnte ich mir load vorstellen, obwohl man ja auch die Zeilen hinzu adden kann.
Wie verteile ich die auf jedes passende das Gegenstück?
Die muss man ja irgendwie bezeichnen, das er weiß welches wo hin soll.

_________________
|x-32:88x+39-3|+3:21=47-4x
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 07.04.07 16:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var aStringlist: TStringlist; 
//.. 
aStringlist := TStringlist.Create; 
aStringlist.LoadFromFile('c:\MeineDatei.txt'); 
Edit1.Text := aStringlist[0];
//...
aStringlist.Free;

Ein Blick in die Hilfe hätte das aber auch klären können ;-)

_________________
We are, we were and will not be.