{ -------------------------------------------------------------------------- } { BigIni.PAS eh970825 } { Version 2.01 } { Unit to read/write *.ini files even greater than 64 kB } { (till today, the KERNEL.DLL and KERNEL32.DLL do it NOT). } { (c) Edy Hinzen 1996/97 - Freeware } { Mailto:Edy@Hinzen.de (thanks for the resonance yet!) } { http://www.Hinzen.de (where you find the latest version) } { -------------------------------------------------------------------------- } { The TBigIniFile object is designed to work like TIniFile from the Borland } { unit called IniFiles. } { Opposite to the Borland-routines, these are declared virtual! } { Please note that no exception-handling is coded here. } { The following procedures/functions were added: } { procedure FlushFile write data to disk } { procedure ReadAll copy entire contents to TStrings-object} { procedure AppendFromFile appends from other *.ini } { property SectionNames } { -------------------------------------------------------------------------- } { The TBiggerIniFile object is a child object with some functions that came } { in handy at my projects: } { property TextBufferSize } { procedure WriteSectionValues(const aSection: string; const aStrings: TStrings);} { analog to ReadSectionValues, replace/write all lines from } { aStrings into specified section } { procedure ReadNumberedList(const Section: string; } { Strings: TStrings; } { Deflt: String); } { procedure WriteNumberedList(const Section: string; } { Strings: TStrings); } { -------------------------------------------------------------------------- } { The TAppIniFile object is a child again. } { It's constructor create has no parameters. The filename is the application's} { exename with with extension '.ini' (instead of '.exe). } { constructor Create; } { -------------------------------------------------------------------------- } { For Delphi 1.0 users class TStringList had been redefined and expanded } { with some 2.0 functions/properties } { -------------------------------------------------------------------------- } { ========================================================================== } { This program is distributed in the hope that it will be useful, } { but WITHOUT ANY WARRANTY; without even the implied warranty of } { MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } { ========================================================================== } { Programmer's note: } { Okay, this is NOT the fastest code of the world... (the kernel-functions } { xxxxPrivateProfileString aren't, either!). I wrote it as a subproject of } { my EditCdPlayer.EXE which never seems to become finished ... } { Meanwhile, I hope that Microsoft will write new KERNEL routines. } { Version history } { 1.10 faster read by replaceing TStringlist with simple ReadLn instructions } { improved FindItemIndex by storing last results } { 1.20 Ignore duplicate sections } { improved (for this use) TStringList child TSectionList } { 1.21 fixed 1.20 bug in case of empty file } { 1.22 added ReadNumberedList and WriteNumberedList } { 1.23 Delphi 1.0 backward compatibility e.g. local class TStringList } { 1.24 added AppendFromFile } { 2.00 Changed compare-routines of aSection Parameters to CompareAnsiText } { to handle case insensitive search in languages with special chars; } { some efforts to increase speed } { * new web and e-mail address * } { 2.01 implemented modifications/suggestions from Gyula Mészáros, } { Budapest, Hungary - 100263.1465@compuserve.com } {procedure TIniFile.ReadSections(Strings: TStrings); { - The extra 16K file buffer is removeable (as it has minor effect if } { a disk cache is used (which is the default)) } { see property TextBufferSize } { - comment lines (beginning with ';') can be ignored } { set property FlagDropCommentLines to True } { - invalid lines (which do not contain an '=' sign) can be ignored } { set property FlagFilterOutInvalid to True } { - white spaces around the '='-sign can be dropped } { set property FlagDropWhiteSpace to True } { - surrounding single or double apostrophes from keys can be dropped } { set property FlagDropApostrophes to True } { 2.01 (continued) } { property SectionNames is now part of TBigIni (instead of TBiggerIni} { added procedure ReadSections (seems new in Delphi 3) } { -------------------------------------------------------------------------- } { -------------------------------------------------------------------------- } { Question: how can I set these properties _before_ the files is opened? } { Answer: call create with empty filename, look at this sample: } { myIniFile := TBigIniFile.Create(''); } { myIniFile.FlagDropCommentLines := True; } { myIniFile.FileName := ('my.ini'); } {........................................................................... } { Question: how can I write comment lines into the file? } { Answer: like this: } { tempStringList := TStringList.Create; } { tempStringList.Add('; this is a comment line.'); } { BigIniFile.WriteSectionValues('important note',TempStringList); } { BigIniFile.FlushFile; } { tempStringList.Free; } { -------------------------------------------------------------------------- }