Jooooh, du kan vel lave din egen TIniFile-klasse med nogle ekstra funktioner, men lige hvordan, det ved jeg sgu ikke... Så skal du nok selv til at styre aflæsningen af filen... Der skal du bruge:
var F: TextFile; S, Ident: String; Tal, Code: Integer; begin AssignFile(F, ExtractFilePath(Application.ExeName) + 'IniFil.ini'); Reset(F); while not Eof do begin ReadLn(F, S); Ident := Copy(S, 1, Pos('=', S)-1); if Ident[1] = 'T' then begin Ident := Copy(Ident, 2, Length(Ident)); Val(Ident, Tal, Code); if Code = 0 then ShowMessage('Vi har fundet streng: '+IntToStr(Tal)); end; end; end;
Call ReadSection to retrieve the names of all keys within a specified section of an INI file into a string list object.
Section identifies the section from which to retrieve a list of key names. Strings specifies the string object to hold the retrieved names. Strings can point to a TString object such as a string list, or to a component property, such as Items for a TListBox component, that is a TString object itself.
------ så er det bare at løbe gennem den TStringList du har læst ind i
VAR T : TIniFile; L : TStringList; Cnt : Integer; begin L := TStringList.Create; T := TIniFile.Create('MyIniFileName'); T.ReadSection('Test',L); T.Free; for Cnt := 0 to L.Count-1 do begin if Pos('T',L[Cnt]) = 1 then begin // Lave noget kode her // L[Cnt] indeholder 'T*' end; end; L.Free; end;
ok, brugte lidt fra begge to - så nu virker det sq!
tak...
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.