Mark

Why not use a string indexed array prop?

   TMyObject = class
   private
     function GetValue(const Name: string): Boolean;
    procedure SetValue(const Name, Value: boolean);
   public
     property Options [const Name: string]: boolean read GetBool write
SetValue;
   end;

HTH
Neven


----- Original Message -----
From: Mark Derricutt <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Thursday, 1 March 2001 13:18
Subject: [DUG]: RTTI question


> Is it possible to use RTTI or some other neat trick to do the following..
>
> I have a configuration object thats wrapping properties around an ini
file,
> I have say 10+ boolean properties, and IMHO having 10 get/set routines
that
> do exactly the same thing with a different label just sucks, and isn't
that
> great for ease of maintainability (esp. if the configurable items goes way
> further.
>
> Is it possible to do something like:
>
> type
>   TMyObject = class
>   private
>     function GetBool: Boolean;
>     procedure SetBool(Value: Boolean);
>   public
>     property Bool1: Boolean read GetBool write SetBool;
>     property Bool2: Boolean read GetBool write SetBool;
>   end;
>
> ....
>
> procedure TMyObject.SetBool(Value: Boolean);
> var
>   Key: String;
> begin
>   Key := <insert code to find what property I'm setting>;
>   IniFile.WriteBool('Options', Key, Value);
> end;
>
> function TMyObject.GetBool: Boolean;
> var
>   Key: String;
> begin
>   Key := <insert code to find what property I'm getting>;
>   Result := IniFile.ReadBool('Options', Key, False);
> end;
>
> Is this possible?
>
> Failing that, is this possible:
>
>   function GetBool(Key: String): Boolean;
>   procedure SetBool(Key: String; Value: Boolean);
>
>   property Bool1: Boolean read GetBool('bool1key') write
> SetBool('bool1key');
>
> ???
>
> Mark
>
> --
> There are exceptions, I'm sure, but the Windows 2000 on-line community
> seems to have, in general, the moral and spiritual qualities of your
> average porn site. (c) Bryan Pfaffenberger, Linux Journal, Jan 2001.
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to