Autor Beitrag
Joker_07
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mo 14.07.08 12:38 
Ich möchte bei meinem projekt die werte die in einem Array gespeichert sind in eine textdatei speichern, so dass die einstellungen die vom nutzer betätigt wurden , wie zum beispiel hintergrund des Formulars ändern, nämlich die sollen eben beim nächsten aufruf des Prgramms wieder benutzt werden, indem er anfangs automatisch die textdatei öffnet die zuvor gespeichert wurde ...und die werte in ein Array wieder einliest... wäre nett wenn Ihr mir ne Vorlage geben könntet... danke schon im voraus

Mfg Joker_07


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 14.07.2008 um 13:41
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 14.07.08 12:41 
Moin!

Schonmal in die Suche geschaut? ;) Suche in: Delphi-Forum, Delphi-Library STRINGLIST SAVETOFILE oder Suche in: Delphi-Forum, Delphi-Library STRINGLIST LOADFROMFILE :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mo 14.07.08 12:44 
Hier mal ein Ansatz, du musst natürlich die ZAhlen anpassen und noch ein Paar Variablen und Konstanten deklarieren!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var a: array [1..obergrenze] of shortstring;
var f: file of shortstring;
var i: integer;
assignfile (f, C:\test.txt);
reset (f);
for i:=1 to obergrenze do
begin
write (f, a[i]);
end;
closefile (f);
end;


@Narses:
Er schreibt aber array und nicht stringlist.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Mo 14.07.08 12:45 
Vielleicht hilft dir das auch weiter Suche in der Entwickler-Ecke INIFILES.

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 14.07.08 12:52 
Moin!

user profile iconBoldar hat folgendes geschrieben:
Er schreibt aber array und nicht stringlist.
Dann schreib mal mit deinem Ansatz ein array of String... :zwinker:

Da wird schon noch etwas Arbeit nötig sein, um das komplett anzuwenden - aber wir sind hier ja auch keine Code-Factory, sondern ein Forum! :P

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mo 14.07.08 22:39 
string kann man nicht in Dateien schreiben, nur shortstring.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 14.07.08 22:46 
Moin!

user profile iconBoldar hat folgendes geschrieben:
string kann man nicht in Dateien schreiben, nur shortstring.
:|
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  MyString: String;
begin
  MyString := 'Hallo, ich bin ein dynamischer String! :)';
  FileStream := TFileStream.Create(...
  FileStream.Write(PChar(MyString)^,Length(MyString));
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mo 14.07.08 22:53 
Naja, ich meinte nun auf die "herkömmliche art" und nicht mit streams.
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Mo 14.07.08 23:04 
user profile iconBoldar hat folgendes geschrieben:
Naja, ich meinte nun auf die "herkömmliche art" und nicht mit streams.

Meinst du etwa so?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
{ ungetestet, da Delphi noch nicht reinstalliert :-( }
var
  myFile : TextFile;
  i: integer;
begin
  AssignFile(myFile, 'C:\MyFile.txt');
  Rewrite(myFile);
  for i := 0 to high(myArrayOfString) do
    WriteLn(myFile, myArrayOfString[i]);
  CloseFile(myFile);
end;


Gruß
--