Home / Simple IniFile
Name Modified Size InfoDownloads / Week
Parent folder
ReadMe.md 2024-04-13 4.0 kB
SimpleIniFile.PAS 2024-04-12 18.5 kB
Totals: 2 Items   22.4 kB 0

Simple IniFile

The purpose of this unit is to provide a number of Inifile related untility routines.

Usage

The 'Interface' part of the unit looks as follows (the documentation is self explaining):

interface

uses Classes,
  IniFiles,
  StdCtrls,
  ExtCtrls;

{ ---  Class "TSimpleIniFile" --- }

type
  TSimpleIniFile = class(TIniFile)
  private
    IniFileName: string;
  public
    constructor Create(fn: string = '');
    // Added procedures in this Class with respect to "TIniFile"
    destructor Destroy; override;
    procedure WriteTStrings(const Section, Key: string; Texts: TStrings);
      overload;
    procedure ReadTStrings(const Section, Key: string; Texts: TStrings);
      overload;
    procedure WriteTStrings(const Section: string; Texts: TStrings); overload;
    procedure ReadTStrings(const Section: string; Texts: TStrings); overload;
    procedure WriteObject(const Section: string; Obj: TObject);
    procedure ReadObject(const Section: string; Obj: TObject);
  end;

{ --- Procedures and Functions without usage of a Class --- }

// BinaryStream ----------------------------------------------------
procedure WriteBinaryStreamToIniFile(const Section, Key: string; Value:
  TStream);
function ReadBinaryStreamFromIniFile(const Section, Key: string; Value:
  TStream):
  Integer;

// Bool ----------------------------------------------------
procedure WriteBoolToIniFile(const Section, Key: string; Value: Boolean);
function ReadBoolFromIniFile(const Section, Key: string): Boolean;

// Date ----------------------------------------------------
procedure WriteDateToIniFile(const Section, Key: string; Value: TDateTime);
function ReadDateFromIniFile(const Section, Key: string): TDateTime;

// DateTime ----------------------------------------------------
procedure WriteDateTimeToIniFile(const Section, Key: string; Value: TDateTime);
function ReadDateTimeFromIniFile(const Section, Key: string): TDateTime;

// Float ----------------------------------------------------
procedure WriteFloatToIniFile(const Section, Key: string; Value: Double);
function ReadFloatFromIniFile(const Section, Key: string): Double;

// Integer ----------------------------------------------------
procedure WriteIntegerToIniFile(const Section, Key: string; Value: Integer);
function ReadIntegerFromIniFile(const Section, Key: string): Integer;

// Time ----------------------------------------------------
procedure WriteTimeToIniFile(const Section, Key: string; Value: TDateTime);
function ReadTimeFromIniFile(const Section, Key: string): TDateTime;

// String ----------------------------------------------------
procedure WriteStringToIniFile(const Section, Key, Value: string);
function ReadStringFromIniFile(const Section, Key: string): string;

// TStrings ----------------------------------------------------
procedure WriteTStringsToIniFile(const Section, Key: string; Texts: TStrings);
overload;
procedure ReadTStringsFromIniFile(const Section, Key: string; Texts: TStrings);
overload;
procedure WriteTStringsToIniFile(const Section: string; Texts: TStrings);
overload;
procedure ReadTStringsFromIniFile(const Section: string; Texts: TStrings);
overload;

// Objects Texts and Statusses
procedure WriteObjectToIniFile(const Section: string; Obj: TObject);
procedure ReadObjectFromIniFile(const Section: string; Obj: TObject);

// Miscellaneous ----------------------------------------------------
procedure DeleteKeyFromIniFile(const Section, Key: string);
procedure EraseSectionFromIniFile(const Section: string);
procedure ReadSectionFromIniFile(const Section: string; Texts: TStrings);
procedure ReadSectionsFromIniFile(Texts: TStrings);
procedure ReadSectionValuesFromIniFile(const Section: string; Texts: TStrings);
function SectionExistsInIniFile(const Section: string): Boolean;
function ValueExistsInIniFile(const Section, Key: string): Boolean;

Have fun!

Source: ReadMe.md, updated 2024-04-13