Autor Beitrag
somebody
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Fr 20.07.07 17:22 
Hi Leute,
ich kann mir einfach nicht merken, wer mir irgendwas schuldet und so weiter. Also wollte ich ein Prohgramm schreiben in dem ich eintrage, wer mir was schuldet. So weit geht das auch, nur ich weiß nicht, wie ich das mache, das der das speichert, also auf lange Zeit. Die einzelnen Daten habe ich in Strings gespeichert, nur wie speichere ich diese Strings so ab, das ich das Programm schließen kann und die Daten immer noch gespeichert sind, bis ich sie löche? Weil normalerweise speichert delphi das ja nur solange das Programm auch läuft.
Ich hoffe ich konnte das so erklären, dass ichr wisst was ich fü ein Problem habe.

mfg:Somebody


Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Fr 20.07.2007 um 18:27
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 20.07.07 17:26 
Moin!

Suche in: Delphi-Forum, Delphi-Library TSTRINGLIST ist dein Freund, und die Methoden .LoadFromFileund .SaveToFile()auch. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Fr 20.07.07 17:44 
Ich habe jetzt was gefunden, aber das geht irgendwie net. Ich habe erstmal als test etwas in die txt reingeschrieben, das soll dann ausgegeben werden.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
    Ttext = array[1..2] of string;
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Datei: Ttext;
  TFile: Textfile;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var z: integer;
begin
     AssignFile(Tfile,'C:\Daten.txt');
     for z:=1 to 2 do
     edit1.text := Tfile, Datei[z];
end;

end.


Das geht aber iwie net, was ist daran falsch.

mfg:Somebody
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Fr 20.07.07 17:51 
Warum ignorierst Du (anscheinend) user profile iconNarses Antwort :?:

Und wenn Du schon via Copy&Paste programmierst, versuch es richtig abzutippen & lass nicht irgendwelche Quellcodezeilen weg...

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Sa 21.07.07 10:47 
Ich habe die Antwort von user profile iconNarses nicht ignoriert, ich habe in seiner Suchanfrage rumgeguckt. Aber mit der Antwort von user profile iconNarses also, das andere da, damit habe ich noch mehr Probleme, da ich nichnt weiß wie das geht, weil ich damit noch nie gearbeitet habe. Könnte mir vll irgendwer sagen, wie es richtig geht?

mfg:somebody
pigfacejoe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 332
Erhaltene Danke: 1

Win 10, Ubuntu
Delphi,Javascript, PHP, Java, Python
BeitragVerfasst: Sa 21.07.07 10:52 
Also du kannst entweder Komponenten benutzen :
-Memo
-Listbox
-...
oder einfach eine variable vom Typ TStrings deklarieren. Diese hat dann die Eigenschaft SaveToFile sowie LoadFromFile.

Bei einer Listbox zum Bsp sieht das dann so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
Listbox1.items.savetoFile('C:\bla.txt'); //Speichern

Listbox1.items.LoadFromfile('C:\bla.txt'); //Laden

So einfach.
Ein bisschen Suchen hätte dir da geholfen..
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Sa 21.07.07 10:58 
...oder die von Narses erwähnte TStringList:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    B_Laden: TButton;
    B_Speichern: TButton;
    procedure B_LadenClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure B_SpeichernClick(Sender: TObject);
  private
    { Private-Deklarationen }
    StringList: TStringList;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  StringList:= TStringList.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  StringList.Free;
end;

procedure TForm1.B_LadenClick(Sender: TObject);
var
  i: integer;
begin
  StringList.LoadFromFile('C:\Test.txt');
  Memo1.Clear;
  for i := 0 to StringList.Count - 1 do
    Memo1.Lines.Add(StringList.Strings[i]);
end;

procedure TForm1.B_SpeichernClick(Sender: TObject);
var
  i: integer;
begin
  StringList.Clear;
  for i := 0 to Memo1.Lines.Count -1 do
    StringList.Add(Memo1.Lines.Strings[i]);
  StringList.SaveToFile('C:\Test.txt');
end;

end.


All right?

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Sa 21.07.07 11:01 
thx, es geht.

mfg:somebody
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Sa 21.07.07 11:08 
Gibt es auch noch eine Funktion um Sachen aus der txt zu löschen?
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Sa 21.07.07 11:11 
user profile iconsomebody hat folgendes geschrieben:
Gibt es auch noch eine Funktion um Sachen aus der txt zu löschen?

Funktioniert Dein F1 nicht?!?

Du hast so lustige Methoden wie Add(), Clear(), Delete(), Insert(), Exchange(),... zur Verfügung

F1 !!!!

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
pigfacejoe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 332
Erhaltene Danke: 1

Win 10, Ubuntu
Delphi,Javascript, PHP, Java, Python
BeitragVerfasst: Sa 21.07.07 11:17 
F1 oder einfach mal www.googleistdeinfreund.de
...
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Sa 21.07.07 11:18 
Das ist mir schon klar, Ok es war sch... Formuliert. ABer ich meinte eigentlich, wie man es macht das man eine "markierte Zeile" in der Listbox löscht. Wie man die ganze listboxlöscht und so, das weiß ich.
pigfacejoe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 332
Erhaltene Danke: 1

Win 10, Ubuntu
Delphi,Javascript, PHP, Java, Python
BeitragVerfasst: Sa 21.07.07 11:19 
F1 oder einfach mal www.googleistdeinfreund.de
...
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 21.07.07 11:21 
Da das nichts mehr mit Speichern zu tun hat, mach ich hier mal dicht. Bitte erstelle für die andere Frage einen neuen Thread, oder bemühe die Forensuche - sowas war bestimmt schonmal irgendwo da. ;-)

Danke!

_________________
We are, we were and will not be.
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.