Autor Beitrag
Luzifer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Do 17.03.05 16:12 
hi leute ich möchte gerne daten in ein textdatei exportieren, aber so dass man sie dann ganz normal mit nem editor etc lesen kann, also nicht via "record" .....


Moderiert von user profile iconAXMD: Topic aus CLX / Delphi Language (Object-Pascal) verschoben am Do 17.03.2005 um 16:16
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Do 17.03.05 16:15 
Hallo Luzifer,

wo kommen denn die Daten her? Datenbank, Tabellenkalkulation, ...

_________________
Live long and prosper
MrSpock \\//
Siluro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Do 17.03.05 16:17 
Was ham die Daten denn fürn Format, bzw. in was für na Komponente liegen die?
Bei nem Memo würde ich zum Beispiel

ausblenden Delphi-Quelltext
1:
memo1.lines.savetofile('filename');					


machen
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Do 17.03.05 16:44 
ich dachte an die inhalte von stringvariablen, funktioniert die savetoFile funktion auch bei denen? wenn ja, wie?
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: Do 17.03.05 16:53 
Ne, das geht glaub ich nicht. ;)

Du kannst es aber so machen: (wäre auch als Funktion zu überlegen)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure Tralala;
var
TempMemo: TMemo;
MeinText: String;
begin
TempMemo := TMemo.Create(Form1);
TempMemo.Text := MeinText;
TempMemo.Lines.SaveToFile('file.txt');
TempMemo.Free;
end;


Jetzt hüpfen mir bestimmt hunderte von Extrem-Delphi-Proggern in den Rücken und meinen, dass das mit der Speicherverwaltung kacke ist und so, aber ich glaub nicht, dass das was macht, weil wir's ja direkt danach wieder freigeben. ;)

kA.... :lol:


//EDIT: Das "Ne, das geht glaub ich nicht." da oben hat sich auf eine direkte Speicherung bezogen... Also z.B. MeinText.SaveToFile(); oder sowas... ;) So wie's jasocul schreibt ist's natürlich auch möglich.... ;)


Zuletzt bearbeitet von WeBsPaCe am Do 17.03.05 16:55, insgesamt 2-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 17.03.05 16:53 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var 
  F: TextFile;
  S: string;
begin
  s := 'HALLO DATEIINHALT';
  AssignFile(F, 'DATEI.TXT');
  Rewrite(F);
  Writeln(F, S);
  CloseFile(F);
end;

Ich fürchte nur, dass dir das nicht wirklich weiter hilft. Du musst dich da schon ein bisschen mit Dateiverarbeitung auseinander setzen.
Siluro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Do 17.03.05 16:54 
Ne, bei Variablen funktioniert das nicht, wüsste jetzt auch spontan nicht wie man eine Variable in eine Datei speichert.
Ich würde mir halt ne Memovariable anlegen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure
var m: TMemo;
begin
  m:=TMemo.Create(self);
  m.parent:=DeinHauptformular;
  m.visible:=false;
  ...
  m.lines.add(DeineStrigvariable);
  m.lines.savetofile(DateiName);
  m.free;
end;


Ist bestimmt nicht der professionelste Weg, aber funktioniert.
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 17.03.05 16:58 
TMEMO für sowas :rofl:
Wenn schon, dann doch bitte eine TStringList.
Ihr nehmt wohl auch einen LKW, um eine Packung Kuagummi zu kaufen, oder? :wink:
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Do 17.03.05 17:07 
sehr gut, danke euch

@jasocul: das funktioniert soweit ganz gut! kann ich da jetzt eigentlich auch zeilenumbrüche (zB mit ASCII #10/#13) einfügen?
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 17.03.05 17:56 
Brauchst du nicht. Jedes Writeln macht am Ende einen Zeilenumbruch.
Luzifer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

WinXP Pro/ Vista
D5 Enterprise/D7 Enterprise/D2005 Architect
BeitragVerfasst: Do 17.03.05 17:57 
sehr gut, dankeschön!!!!