Autor Beitrag
Kaspar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: So 22.01.06 17:59 
Hallo Zusammen,

Giebt es eine Möglichkeit einen bestimmten Schlüssen aus allen Sections einer INI Datei auszulesen?
Also wenn ich zb. folgendes in der INI habe:

[SectionA]
WertA=1
WertB=2

[SectionB]
Werta=1
WertB=2

[SectionC]
Werta=1
WertB=2

Nun möchte ich z.B den "WertB" aus allen Sections auslesen.
Giebts da eine einfache möglichkeit? Also natürlich kann ich jeden Wert einzeln auslesen, aber da ich recht viele Sections habe, ist das halt unpracktisch.
Bin für jede Hilfe sehr Dankbar!

Gruss Kaspar
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 22.01.06 18:01 
du kommst über ReadSections des TIniFile Objektes an alle Sections, die in der INI datei sind ran. Dann kannst du diese Liste einfach durchgehen und alle Weter, die du willst auslesen.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Kaspar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: So 22.01.06 18:17 
Danke für die Antwort.
Also dann muss ich doch das trozdem "Manuell" machen oder?
Am besten wäre ja wenn es mit ner Schleiffe geht. Ist das irgendwie möglich?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 22.01.06 18:25 
Gewiss ist das möglich! :wink:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var list:TStringlist;
i:integer//i muss lokal deklariert werden!!!!
s:string//nur hier im Bsp. verwendet


list:=TStringlist.create;
ini.readsections(list);
for i := 0 to list.count-1 do
begin
     //jetzt kommts drauf an, was du damit machen willst und welcher Datentyp (string,int...)
     s:=ini.readstring(list.strings[i],'WertB',s);
     showmessage(s);
end;


Der Teil innerhalb der Schleife ist ausgedacht, ich weiß ja nicht was du mit diesen Werten anstellen willst. In eine Listnbox eintragen oder was? Vielleicht bekommst du das ja selbst hin, wenn nicht, dann frag nochmal nach :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Kaspar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: So 22.01.06 22:19 
Hat alles wunderbest geklappt :)
Vieelen Dank!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 23.01.06 02:41 
...