Autor Beitrag
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 03.04.03 20:01 
Habe ein Programm mit einer ini-Datei, in der ca. 100 Variablen gespeichert werden. Bei Programmende soll die IniDatei aktualisiert werden. Also schreibe ich sämtliche werte in die Datei mit den entsprechenden Funktionen für iniDateien.

Jetzt hab ich mal spasseshalber das Programm von Diskette gestartet.
Das Schreiben der Ini hat da ungefähr 2 Minuten gedauert.

Kann man das schneller machen?
(klar kann man, aber wie?)[/code]

_________________
We are, we were and will not be.
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Do 03.04.03 20:02 
Ohne deinen Quelltext zu sehen schwer zu sagen. Kristallkugeln sind gerade aus.
Gausi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 03.04.03 20:22 
Ich dachte, das wäre klar, aber gut:
In der onclose procedure der Hauptform steht in etwa so was:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
ini:=tinifile.Create(ChangeFileExt( Application.ExeName, '.INI' ));
    try
        ini.writestring('string1','Dieses Thema',string1);
        ini.writeinteger('int20','anderes Thema',int20);
        ini.writebool('bool1',und wieder was'',bool1);
        //insgesamt ca. 100 Werte
    finally
       ini.Free;
    end;

Hab eben das gemacht, wie man Werte in Inis speichert. Wie die Werte zusatnde kommen, ist dabei doch egal, oder?
Ärgerlich finde ich, dass das scheinbar SEHR lange dauert.

_________________
We are, we were and will not be.
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Do 03.04.03 20:26 
Nein, das war nicht klar, vielleicht hätte es auch woanders dran gelegen.
Aber Inifiles sind langsam, das lässt sich nicht ändern. Bei jedem Aufruf einer Writefunktion wird die gesamte Datei neugeschrieben.
Gausi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 03.04.03 20:42 
hmm...und da kann man nix dran machen?
Denn dann ist klar, warum das lang dauert: 100 mal ne kleine Textdatei auf Diskette zu schreiben dauert eben.

Dann mach ich das wohl besser so, dass ich die IniDatei "per Hand" selbst komplett neu schreibe. Ist wohl ein bissel mehr Code, aber dann ungefähr 100 mal schneller...

_________________
We are, we were and will not be.
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Do 03.04.03 20:48 
@Gausi

TStringList bietet einige Möglichkeiten mit denen man das Arbeiten mit einer Ini simmulieren kann. Guck dir dazu follgende Punkte an:

TStrings.Values
TStrings.Names
TStrings.IndexOfName

Worauf ich hinauswill - du könntest zuerst alle Werte in einer Stringlist speichern und dann die ganze StringList in einem Rutsch sichern.

_________________
Popov
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 03.04.03 20:53 
Schau doch mal in der Hilfe nach TMemIniFile, die puffert das Ganze im Speicher und dann kannstes (nach meiner Meinung, habs no net verwendet) in einem Rutsch schreiben.

Gruß
Gausi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 03.04.03 20:57 
die letzten beiden Beiträge gefallen mir ganz gut. Werde mal beides ausprobieren, mit TMemIniFile fang ich an ;-)

Danke für die Hilfe!

_________________
We are, we were and will not be.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Fr 04.04.03 11:05 
Hallo,
wenn du ein Beispiel (bzw. Testprogramm) zu tMemIniFile gebrauchen kannst, findest du es hier.

Gruß
Klabautermann
Gausi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 04.04.03 14:00 
Das mit TMemIniFile klappt wunderbar. Laufwerk A rattert beim beenden des Programms jetzt nur einmal kurz, die Datei wird jetzt einmal geschrieben, nicht mehr 100mal

@Klabautermann: Danke für den Hinweis, aber ich brauchte nur 2mal "ini" durch "memini" ersetzten (einmal bei der deklaration der Variablen, und bei create) und eine Zeile Code hinzufügen (ini.updatefile).
Das hab ich auch so hingekriegt :D

_________________
We are, we were and will not be.