Autor Beitrag
awzvm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Mo 02.03.09 17:00 
Hallo zusammen,

ich habe das Problem, dass beim Auslesen einer Zeile, diese auf knapp 3.000 Zeichen abgeschnitten wird. Aber nur warum?

Ich beschreibe eine Ini-Datei wie folgt:
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:
 ini:=TIniFile.Create(Filename);
//...
 For zeile:=0 to StringGrid_Leistungsbaum.RowCount-1 do
  Begin
   Ini.WriteString(Baum,InttoStr(zeile),StringGrid_Baum.Cells[0,zeile] + ';' +
                 StringGrid_Baum.Cells[1,zeile] + ';' +
                 StringGrid_Baum.Cells[2,zeile] + ';' +
                 StringGrid_Baum.Cells[3,zeile] + ';' +
                 StringGrid_Baum.Cells[4,zeile] + ';' +
                 StringGrid_Baum.Cells[5,zeile] + ';' +
                 StringGrid_Baum.Cells[6,zeile] + ';' +
                 StringGrid_Baum.Cells[7,zeile] + ';' +
                 StringGrid_Baum.Cells[8,zeile] + ';' +
                 StringGrid_Baum.Cells[9,zeile] + ';' +
                 StringGrid_Baum.Cells[10,zeile] + ';' +
                 StringGrid_Baum.Cells[11,zeile] + ';' +
                 StringGrid_Baum.Cells[12,zeile] + ';' +
                 StringGrid_Baum.Cells[13,zeile] + ';' +
                 StringGrid_Baum.Cells[14,zeile] + ';' +
                 StringGrid_Baum.Cells[15,zeile] + ';' +
                 StringGrid_Baum.Cells[16,zeile] + ';' +
                 StringGrid_Baum.Cells[17,zeile] + ';' +
                 StringGrid_Baum.Cells[18,zeile] + ';' +
                 StringGrid_Baum.Cells[19,zeile] + ';;' +
                 StringGrid_Baum.Cells[20,zeile] + ';' +
                 StringGrid_Baum.Cells[21,zeile] + ';;;;' +
                 StringGrid_Baum.Cells[22,zeile] + ';;;;;;;' +
                 StringGrid_Baum.Cells[23,zeile] + ';;' +
                 StringGrid_Baum.Cells[24,zeile] + ';;' +
                 StringGrid_Baum.Cells[25,zeile] + ';' +
                 StringGrid_Baum.Cells[26,zeile]);

  end;


Dabei schreibe ich Zeilen weg, welche auch mal 20.000 Zeichen beinhalten können.

Beim Auslesen werde diese jedoch abgeschnitten :-( Die Zeilen sind dann nur noch kanpp 3.000 Zeichen lang und viele Informationen gehen verloren.
So lese ich wieder aus:
ausblenden 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:
ini := TIniFile.Create(OpenDialog1.FileName);
    try
//...
  For zeile:=1 to StringGrid_Baum.RowCount do
   Begin
    //Parsen der Zeilen
    startPos:=1;
    buffer:=Ini.ReadString('Baum',IntToStr(zeile),';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;');
    //ShowMessage(IntToStr(length(buffer)));
    //In Spalte 0 kommt erster Wert
    spalte:=0;
    For i:=0 to 38 do
     begin
       endPos := PosEx(';',buffer,startPos);
       IF endPos=0 then endPos:=length(buffer)+1;
       If (i=0) OR (i=1) OR (i=2) OR (i=3) OR (i=4) OR (i=5) OR (i=6) OR (i=7) OR (i=8) OR (i=9) OR (i=10) OR (i=11) OR (i=12) OR (i=13) OR (i=14) OR (i=15) OR (i=16) OR (i=17) OR (i=18) OR (i=19) OR (i=21) OR (i=22) OR (i=26) OR (i=33) OR (i=35) OR (i=37) OR (i=38) then
        begin
          StringGrid_Baum.Cells[spalte,zeile]:=copy(buffer,startPos,endPos-startPos);
          inc(spalte);
        end;
       startPos:=endPos+1;
     end;
    end;


buffer ist vom Typ String.

Woran kann das liegen, das bei Ini.Readstring nicht alles gelesen wird und wie kann ich das Problem beheben?

Viele Grüße
awzvm
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 02.03.09 17:07 
weil tstring nur eine begrenzte anzahl an Zeichen speichern kann. Kann sein das die erreicht ist. Warum speicherst du überhaupt so lange strings? Mach doch mehrere einezlschlüssel
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 02.03.09 17:11 
Moin!

user profile iconBoldar hat folgendes geschrieben Zum zitierten Posting springen:
weil tstring nur eine begrenzte anzahl an Zeichen speichern kann.
Kann sein, du meinst TIniFile? Strings dürften hier wohl nicht an ihre Grenze kommen. ;)

user profile iconBoldar hat folgendes geschrieben Zum zitierten Posting springen:
Warum speicherst du überhaupt so lange strings? Mach doch mehrere einezlschlüssel
Ich würde hier eher das CSV-Format vorschlagen und erst gar keine INI-Datei nehmen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
awzvm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Mo 02.03.09 19:41 
Ein String sollte diese Zeichenlänge können.
In der Ini-Datei sind noch Zeichen enthalten (das Schreibe von langen Werten geht also).
Leider kann ich diese nicht aufgeschlüsselt wegschreiben, da einige Einzelwerte extrem lang sind.

Gibt es eine Möglichkeit, lange Strings von INI-Dateien zu lesen?

Schönen Abend wünscht
awzvm
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 02.03.09 19:59 
user profile iconNarses hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconBoldar hat folgendes geschrieben Zum zitierten Posting springen:
Warum speicherst du überhaupt so lange strings? Mach doch mehrere einezlschlüssel
Ich würde hier eher das CSV-Format vorschlagen und erst gar keine INI-Datei nehmen. :idea:

Hast du dir diese Idee schon mal durch den Kopf gehen lassen? Eine CSV wäre in (fast) jedem Fall besser geeignet für eine Tabelle. Wenn du mehrere Tabellen speichern musst, könntest du dir die [SECTIONS] auch selber parsen lassen. Wäre ja kein so großer Aufwand.
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 02.03.09 20:00 
Moin!

OK, nochmal deutlicher: dein Konzept (in diesem Fall) auf INI-Dateien zu setzen ist daneben. :nixweiss: Warum muss es unbedingt INI sein? Was spricht gegen CSV? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
WASEO
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 56

Win98, Win2000, WinXP
D6 Prof, D7 Prof
BeitragVerfasst: Mo 02.03.09 23:12 
Moin!

Sorry, muss hier mal was aufklären:

a) TStrings kann seit Delphi 2 beliebig lange Zeichenketten verarbeiten, die Grösse ist praktisch nur durch die Speicherkapazität des Rechners begrenzt.

b) INI-Dateien wurden schon unter Windows 3.1 benutzt, daher sind sie standardmässig auf 64k (65.536 Zeichen) insgesamt begrenzt.

c) Google mal nach "BigINI". Das ist eine Freeware-Unit, die keine Grössenbeschränkung hat.

Gruss
WASEO

_________________
Erstaunlich sind nicht die Dinge, die wir nicht kennen, sondern die wir kennen und die nicht so sind.
awzvm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Di 03.03.09 08:35 
Hallo zusammen,

danke für die vielen Denkanstöße.

Ich hatte vor, viele Kleine CSV-Dateien in eine INI-Datei zu schreiben und sie so als "Paket" abzulegen. Es war vll. doch nicht die Beste Wahl, auf das veraltete INI-Format zu setzen, da dieses echt begrenzt ist.

BigIni sollte da schon helfen. Beim Googeln hab' ich jedoch noch eine weiter Klasse, welche Delphi mitbringt entdeckt TMemIniFile.
Ich habe alle TIniFile durch TMemIniFile ersetzt und nun klappt es auch mit extrem langen Strings. Selbst die Syntax für Schreiben und Lesen musste nicht angepasst werden.

Ging so also schnell zu lösen.

Danke dafür. :flehan:

Viele Grüße
awzvm
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 03.03.09 09:14 
Trotzdem solltest du die Beiträge, dass INI dafür nicht unbedingt geeignet ist, nicht außer acht lassen!

_________________
In the beginning was the word.
And the word was content-type: text/plain.