Autor Beitrag
kartoffelkaefer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23



BeitragVerfasst: Mi 27.02.08 19:42 
Hallo,
ich habe ein Problem mit dem laden von Ini Dateien. Das speichern funkrioniert, doch wenn cih danach wieder laden möchte gitb er mir nichts aus. Hier der Quelltext:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button2Click(Sender: TObject);
var ini: TIniFile;
begin
  ini:=TIniFile.Create('einstellungen.ini');
  try
    edit3.text:=ini.Readstring('Name','Vorname','0');
    edit4.text:=ini.Readstring('Name','Nachname','0');
  finally
    ini.free;


end;
end;
[code]
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Mi 27.02.08 19:50 
Wie "schreibst" Du Deine INI?

Gruß
Crowbar


Zuletzt bearbeitet von Crowbar am Mi 27.02.08 19:54, insgesamt 1-mal bearbeitet
kartoffelkaefer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23



BeitragVerfasst: Mi 27.02.08 19:53 
ok danke, aber was ist wenn ich gar keine vars benutze sondern die dateien vorher so speicher:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var ini: tinifile;
begin
ini:=tinifile.create(ExtractFilePath(ParamStr(0))+
    'einstellungen.ini');
ini.writestring('Name','Vorname',edit1.text);
ini.writestring('Name','Nachname',edit2.Text);
ini.free;
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: Mi 27.02.08 19:55 
@Crowbar: Nein, da kommen die Default-Werte rein, das ist also so schon richtig.

Problem dürften hier wieder die relativen Pfade sein...das hatte ich daoch eben schonmal geschrieben. Wahrscheinlich wird die ini-Datei in ein Verzeichnis geschrieben, und aus einem anderen geladen. Daher: Immer den ganzen Pfad zum Speichern und Laden angeben!

_________________
We are, we were and will not be.
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Mi 27.02.08 19:56 
@Gausi: Ups, stimmt ... schon korrigiert! :wink:
Es scheint so, als ob die Ini-Datei nicht gefunden wird:

siehe:
ausblenden Delphi-Quelltext
1:
 ini:=TIniFile.Create('einstellungen.ini');					

ausblenden Delphi-Quelltext
1:
ini:=tinifile.create(ExtractFilePath(ParamStr(0))+'einstellungen.ini');					


Zwei unterschiedliche Zuweisungen (einmal mit und einmal ohne ExtractFilePath(ParamStr(0)) für die ini-Datei.
kartoffelkaefer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23



BeitragVerfasst: Mi 27.02.08 20:03 
ok danke, jetzt funktioniert es, lag an dem Pfad.