Autor Beitrag
der Berliner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: So 11.05.08 16:42 
Schöne Pfingsten zusammen

Also ich hab ne INI Datei nach folgendem Muster:
[Einheit]
1=bar
2=mbar
3=Torr
... usw.

Wenn ich nun mit
ausblenden Delphi-Quelltext
1:
Ini.ReadSectionValues('Einheit',Lisbox1.Items);					


die Werte der Eigenschaften 1 -. .. in eine Listbox schreiben will
dann steht in der Listbox

  • 1=bar
    2=mbar

und ich hätte gerne

  • bar
    mbar


Weis da wer Rat, bin für jede Hilfe dankbar.
Gruß
Andre

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
der Berliner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 417

Win Xp Home
delphi 2005
BeitragVerfasst: So 11.05.08 18:58 
Ok...hab das problem Inzwischen gelöst.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
   with ini do
   begin
    ReadSection ('Einheit', sl); //sl = StringList
    ShowMessage(IntToStr(sl.Count));
     for i := 0 to sl.Count - 1 do
     begin
      LBox_Von.Items.Add(readString('Einheit',sl.Strings[i],'Fehler'));
      LBox_Nach.Items.Add(readString('Einheit',sl.Strings[i],'Fehler'));
     end;
   end;
  ini.Free;
end;


Gruß Andre

_________________
[b]Ich weiß nicht immer, wovon ich rede. Aber ich weiß, dass ich recht habe.[b]
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 12.05.08 11:36 
Hallo,

Du kannst auch Values und Names einer StringList dafür verwenden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var ini : TInifile;
    sL  : TStringList;
    z   : Integer;
begin
  ini := TIniFile.Create('c:\temp\XXX.ini');
  sL  := TStringList.Create;
  try
    ini.ReadSectionValues('DAT',sL);
    for z := 0 to sL.Count -1 do
      ListBox1.Items.Add(sL.Values[sL.Names[z]]);
  finally
    sL.Free;
    ini.free;
    end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Cronen
Hält's aus hier
Beiträge: 2


Turbo Delphi W32 Prof
BeitragVerfasst: Mo 12.05.08 12:04 
Eine Frage zum Vorschlag von Lannes:

Warum der Weg über eine extra Stringlist und nicht direkt

ausblenden Delphi-Quelltext
1:
ini.ReadSectionValues('DAT',ListBox1.Items);					


Ich hätte hier doch gleich das Problem einer leeren Liste mit gelöst.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 12.05.08 12:08 
Hallo,
user profile iconCronen hat folgendes geschrieben:
Warum der Weg über eine extra Stringlist und nicht direkt

weil ReadSectionValues Schlüssel und Wert ausgibt:
ausblenden Quelltext
1:
2:
3:
1=bar 
2=mbar 
3=Torr

user profile iconder Berliner möchte aber nur die Werte :wink:

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )