Autor Beitrag
Nano-Ware
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Di 19.01.10 16:55 
Hi,

ich will einfach nur wissen, wie man einen Text an eine Datei anhängt^^

weil sobald ich rewrite(f) benutze ist due Datei wieder leer^^ gib es auch ne möglichkeit ohne erst den ganzen Inhalt auszulesen und dann später wieder zu schreiben? Ich habs auch mal ohne rewrite versucht geht leider nicht


Zuletzt bearbeitet von Nano-Ware am Di 19.01.10 17:19, insgesamt 1-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8549
Erhaltene Danke: 478

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.01.10 16:58 
Das sollte mit Append anstelle von Rewrite gehen.

_________________
We are, we were and will not be.
Nano-Ware Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Di 19.01.10 16:58 
Also einfach Append(f)?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 19.01.10 17:00 
Ganz genau. ;-)
Warum probierst du es nicht einfach aus?
Nano-Ware Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Di 19.01.10 17:01 
Das demotiviert mich immer wenns dann nicht klappt :wink: thx an Gausi und jeannicke^^

EDIT//Hab doch noch ein Problem...

Ich wollte das dafür haben, eine User-Datei, in der alle Users aufgelistet sind (einer pro Zeile)

(z.B)

//#ANFANG#
1.User
2.User
3.User
//#ENDE#

wenn ich es jetzt normal mit Append mache?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
AssignFile(f, 'Users\AllUsers.dat');
  Append(f);
  WriteLn(f, GetUsername);
  CloseFile(f);


Dann hängt er es an den Text an:

//#ANFANG#
1.User
2.User3.User
//#ENDE#

Dann hab ich es so versucht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
AssignFile(f, 'Users\AllUsers.dat');
  Append(f);
  WriteLn(f,#13#10 + GetUsername);
  CloseFile(f);


Perfekt jetzt sieht es so aus:

//#ANFANG#
1.User
2.User
3.User
//#ENDE#

Aber wenn die Users.dat jetzt leer ist, was durchaus mal vorkommt :wink: dann siehts so aus:

//#ANFANG#

1.User
//#ENDE#

Und diese freie Zeile stört leider sehr beim auslesen... wie kann ich das ändern?
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Di 19.01.10 18:02 
Hänge den Zeilenumbruch an, anstatt ihn voranzustellen. Und verwende am besten gleich sLineBreak

ausblenden Delphi-Quelltext
1:
WriteLn(f, GetUsername + sLineBreak);					
Nano-Ware Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 7



BeitragVerfasst: Di 19.01.10 21:13 
Das ist gut^^ wie dumm xD achja noch ganz kurz...

ich frag im so ab

repeat

until line = ''

wird dann die Zeile die durch LineBreak erzeugt wird als '' erkannt oder? Hab grad leider kein Delphi