Autor Beitrag
Hochhäusl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: Do 17.12.09 11:22 
Hallo,

ich habe Versucht nur die Werte einer INI Datei in eine Listbox einzulesen:

ausblenden Delphi-Quelltext
1:
ini.ReadSectionValues('ID',Listbox1.Items);					


Das Problem dabei ist, dass nicht nur die Werte, also zB. 50 sondern "top=50"
in die Listbox geschrieben werden.

Kann man das unterbinden, oder muss ich die Einträge nachträglich bearbeiten/ zuschneiden?
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 17.12.09 11:53 
Kannst es auch so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure ReadSectionValuesWithoutKey(ASource: TIniFile; ASection: String; ADest: TStrings);
var
  Keys: TStrings;
  iKey: Integer;
begin
  Keys := TStringList.Create;
  try
    ADest.Clear;
    ASource.ReadSection(ASection, Keys);
    for iKey := 0 to Keys.Count -1 do
      ADest.Add(ASource.ReadString(ASection, Keys[iKey], ''));
  finally
    Keys.Free;
  end;
end;


Ungetestet!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 17.12.09 13:29 
Moin!

user profile iconHochhäusl hat folgendes geschrieben Zum zitierten Posting springen:
ich habe Versucht nur die Werte einer INI Datei in eine Listbox einzulesen: [...] Kann man das unterbinden, oder muss ich die Einträge nachträglich bearbeiten/ zuschneiden?
Dein Problem sieht so aus, als sei es durch einen falschen Aufbau der INI-Datei als Folge entstanden. Schau doch mal hier, vielleicht bringt das schon den entscheidenden Einfall. :les: :idea: ;)

cu
Narses

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


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 17.12.09 13:49 
Moin,

alternativ empfehle ich FastIniFiles. Dort kannst du, meiner Meinung nach, die Werte mit einer ID (ohne den Namen zu kennen) auslesen.

MfG
Regan
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 17.12.09 14:59 
user profile iconNarses hat folgendes geschrieben Zum zitierten Posting springen:
Dein Problem sieht so aus, als sei es durch einen falschen Aufbau der INI-Datei als Folge entstanden.

Nein nein, das hat schon so seine Richtigkeit. Diese Funktion tut tatsächlich nicht das was dran steht.
Wobei nichts über das Datenmodell des OP gesagt ist, aber mal wieder über die VCL...


Üblicherweise hole ich mir die SectionValues in eine Liste und greife auf diese dann per .ValuesFromIndex[] zu.

Die Version von Andreas geht zwar, ist aber IMHO unnötig langsam.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 17.12.09 15:48 
user profile iconMartok hat folgendes geschrieben Zum zitierten Posting springen:


Die Version von Andreas geht zwar, ist aber IMHO unnötig langsam.


Wenn man TMemIniFile statt TiniFile verwendet, sollten es nur ein paar Milisekunden sein. 8)
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 17.12.09 16:49 
user profile iconAndreas L. hat folgendes geschrieben Zum zitierten Posting springen:
Wenn man TMemIniFile statt TiniFile verwendet, sollten es nur ein paar Milisekunden sein. 8)

Wenn man das macht, kann man sich aber auch gleich die Rohdaten geben lassen. Nichts anderes macht ReadSectionValues da ja.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."