Autor Beitrag
Flash106
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Di 23.08.05 10:55 
Hallo,

ich würde gerne alle Zeilen eines Memos in einer Textdatei speichern. Jedoch nicht Zeilenweise sondern in eine Zeile. Ich speichere zuerst ein paar Daten und dann soll der Memoinhalt hintendran gehängt werden... Wie mach ich das?!?!

Danke schonmal ! =)
MrFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 208

WIN 2000 Professional, Ubuntu 5.10
D3 Prof, D7 Pers, D2005 Pers, Java (Eclipse)
BeitragVerfasst: Di 23.08.05 11:13 
Du öffnest die Textfile ganz normal und hängst Memo.Text hinten dran.
Wenn das nicht geht, kannst du ja alle Zeilenumbrüche durch ersetzen entfernen.

_________________
Das Leben auf der Erde mag zwar teuer sein, aber eine jährliche Rundreise um die Sonne ist gratis mit dabei.
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Di 23.08.05 11:31 
hintendrann hängen geht ja nicht.. ersetzen?! soll ich jedes zeichen auf einen Zeilenumbruch testen?! :(
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 23.08.05 11:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure Store;
var
  strTextToSave: string;
begin
  strTextToSave := StringReplace(Memo.Text, #13#10, '\n');
  { speichern ... }
end;

function Load: string;
var
  strText: string;
begin
  { string aus datei in strText laden }
  Result := StringReplace(strText, '\n', #13#10);
end;

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 23.08.05 11:47 
user profile iconFlash106 hat folgendes geschrieben:
soll ich jedes zeichen auf einen Zeilenumbruch testen?! :(

Genau. Durch die Funktion da einfach erst den Memo1.Text durchjagen vorm Speichern. ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function DeleteReturns(AString: String): String;
var
  i: Integer;
begin
  Result := '';
  for i := 0 to Length(AString) do
    if (AString[i] = Chr(10)) or (AString[i] = Chr(13)) then
      Continue
    else
      Result := Result + AString[i];
end;


//EDIT: Zu spät. :motz: ;)
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: Di 23.08.05 11:57 
Hallo,

oder so ähnlich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var z : Integer;
    s : String;
begin
  for z := 0 to Memo1.Lines.Count-1 do
      s := s+Memo1.Lines[z];
  Memo1.Lines.LoadFromFile('C\Temp\beispiel.txt');
  Memo1.Lines.add(s);
  Memo1.Lines.SaveToFile('C\Temp\beispiel.txt');

alternativ mit einer StringListe.

//EDIT: Noch später. :motz: :wink:

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


D7 Ent
BeitragVerfasst: Di 23.08.05 12:03 
:oops: ok thx! hab ich da etwas doof angestellt. funzt... thx!!