Autor Beitrag
toxicmaster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 23.12.04 10:36 
hi,

ich habe eine frage,
nämlich wie kann ich einen text aus einer txt datei löschen???? (den gesamten text mit einem buttonklick)

habe da was in der delphi-hilfe gefunden
ausblenden Delphi-Quelltext
1:
procedure Delete(Index: Integer); override;					


und mein vorschlag war dann.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button4Click(Sender: TObject);
begin
Delete((ExtractFilePath(Application.exename)+'notiz.txt'): Integer);
override;
end;

das ExtractFilePath(Application.exename)+'notiz.txt' ist der pfad der datei, denn die txt datei ist im ordner wo die exe datei ist.

1. mir wird gesagt, nicht genügend parameter und dann kann er es nicht compilieren.
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 23.12.04 10:41 
Indem du die Datei überschreibst.
Schau mal bei Rewrite in der Delphi Hilfe.

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 23.12.04 10:48 
ausblenden Delphi-Quelltext
1:
Rewrite(var F: File [; Recsize: Word ] );					

das wird mir ausgespuckt.
ist file jetzt mein dateifpad?
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 23.12.04 11:03 
www.delphi-forum.de/...r=asc&highlight= ;)

Nein, File ist nicht dein Pfad.
File ist eine Variable vom Typ File und was man damit machen kann steht auf der selben Seite,
wo du diesen Quelltext von oben her hast. Lies es doch bloß mal durch :roll:

Delphi Hilfe hat folgendes geschrieben:
F ist eine Variable eines beliebigen Dateityps, die zuvor mit AssignFile einer externen Datei zugewiesen wurde. RecSize ist ein optionaler Ausdruck,

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 23.12.04 11:34 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button4Click(Sender: TObject);
var
filename: textfile;
begin
AssignFile(filename, trim(ExtractFilePath(Application.exename))+'notiz.txt');
Rewrite(var filename: File [; Recsize: Word ] );
CloseFile(filename);
end;


was isn hier falsch???
das var und so oder?


Zuletzt bearbeitet von toxicmaster am Do 23.12.04 11:39, insgesamt 1-mal bearbeitet
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 23.12.04 11:37 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button4Click(Sender: TObject);
var
filename: textfile;
begin
  AssignFile(filename, trim(ExtractFilePath(Application.exename))+'notiz.txt');
  Rewrite(filename); // So sollte es stimmen
  CloseFile(filename);
end;
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 23.12.04 11:41 
okay danke funzt!
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 23.12.04 11:41 
Manchmal verspüre ich echt den Schmertz. :autsch:
Du musst schon das entsprechende einsetzen.
In der Delphi Hilfe steht die Syntac beschrieben!
Das heißt welche Anforderungen das was du da einsetzt erfüllen musst.
Ein Var heißt nix anderes, als dass diese Funktion/Prozedur die Variable die danach kommt
verändern kann. Ist ja auch sinnvoll - hier soll ihr was zugewiesen werden.
Heißt also du musst das var weglassen.
Der ":" hinter den Variablen gibt dir an, von welchem Typ die Variable sein muss.
Den darfst du auch nicht übernehmen.
Eckige Klammern sagen dem Delphi Programmierer, dass dieser Wert optional ist.
Also kannst du den Teil komplett weglassen.

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 23.12.04 11:43 
Basti hat folgendes geschrieben:
Eckige Klammern sagen dem Delphi Programmierer, dass dieser Wert optional ist.
Gar nicht wahr. Das ist dann ein Array. :mrgreen: ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 23.12.04 11:50 
Erzähl ihm doch nicht so was.
Da kommt man als Einsteiger durcheinander!
Ich meine eckige Klammern um eine Parameterbeschreibung in der Delphi Hilfe. :twisted:
War das jetzt ein-eindeutig?

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 23.12.04 16:08 
aha. woher soll ich das denn als anfänger wissen. :oops:
nagut aber wenigstens habe ich selbst herraus bekommen, was davor und dahinter muss. :wink: