home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibylft1.zip
/
DOC.DAT
/
DOC
/
SPCC
/
INIFILES.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-04-07
|
4KB
|
113 lines
{╔══════════════════════════════════════════════════════════════════════════╗
║ ║
║ Sibyl Portable Component Classes ║
║ ║
║ Copyright (c) 1995,97 SpeedSoft Germany, All rights reserved. ║
║ ║
╚══════════════════════════════════════════════════════════════════════════╝}
unit IniFiles;
{ TIniFile: Standard (binäres) OS/2 Inifile
TAsciiIniFile: Text-Inifile, lesbar, mit Editor zu bearbeiten.
Beide benutzen exakt das gleiche Interface und sind bis
auf die neue Methode 'Erase' kompatibel zu den normalen
Delphi-Inifiles. }
interface
{Rene}
uses Classes,SysUtils;
{$IFDEF OS2}
USES PMSHL; { OS/2 profile functions }
{$ENDIF}
{$IFDEF WIN95}
USES WinBase;
{$ENDIF}
type
EIniFileError = class(Exception);
type
TIniFile = class(TObject)
private
FFileName: PString; // Physical name of file
{$IFDEF OS2}
FHandle: HINI; // Profile handle
{$ENDIF}
function GetFileName: string;
protected
procedure Error(const Msg: string); virtual;
public
constructor Create(const FileName: string);virtual;
destructor Destroy; override;
procedure Erase(const Section, Ident: string); virtual;
procedure EraseSection(const Section: string); virtual;
function ReadString(const Section, Ident, Default: string): string; virtual;
function ReadInteger(const Section, Ident: string; Default: Longint): Longint; virtual;
function ReadBool(const Section, Ident: string; Default: Boolean): Boolean; virtual;
procedure ReadSection(const Section: string; AStrings: TStrings); virtual;
{procedure ReadSections(AStrings: TStrings); fehlt noch}
procedure ReadSectionValues(const Section: string; AStrings: TStrings); virtual;
procedure WriteString(const Section, Ident, Value: String); virtual;
procedure WriteInteger(const Section, Ident: string; Value: Longint); virtual;
procedure WriteBool(const Section, Ident: string; Value: Boolean); virtual;
property FileName: string
read GetFileName;
end;
type
TAsciiIniFile = class(TIniFile)
private
//FFileName: PString; // Physical name of file
FSections: TStringList; // List of sections and their names
FName: PString; // Name of last used section
FList: TStringList; // List of last used section
FChanged: Boolean; // Has the data been changed?
procedure WriteToSection(const Section: string);
function ReadFromSection(const Section: string): Boolean;
//function GetFileName: string;
protected
FTrueString: string[7];
FFalseString: string[7];
FSectionSort: Boolean;
FIdentSort: Boolean;
protected
procedure InitIniFile;VIRTUAL;
public
constructor Create(const FileName: string);virtual;
destructor Destroy; override;
procedure Erase(const Section, Ident: string); override;
procedure EraseSection(const Section: string); override;
function ReadString(const Section, Ident, Default: string): string; override;
function ReadInteger(const Section, Ident: string; Default: Longint): Longint; override;
function ReadBool(const Section, Ident: string; Default: Boolean): Boolean; override;
procedure ReadSection(const Section: string; AStrings: TStrings); override;
procedure ReadSections(AStrings: TStrings);
procedure ReadSectionValues(const Section: string; AStrings: TStrings); override;
procedure Refresh;
procedure WriteString(const Section, Ident, Value: String); override;
procedure WriteInteger(const Section, Ident: string; Value: Longint); override;
procedure WriteBool(const Section, Ident: string; Value: Boolean); override;
property FileName: string
read GetFileName;
property Changed: Boolean
read FChanged write FChanged;
end;
function GetDefaultINI: string;
{ Get name of INI-file that matches program path & name with
extension .INI instead of .EXE }
implementation