Setting property value by name
Asked Answered
T

1

9

In a Delphi class I have some properties that I would like to set by accessing them by their name. Now I use e.g. Settings.AllowSysop := True;

That I would like to do something like Settings('AllowSysop').Value := True;

The reason for this is that when setting what my users can access this is read from a license file where the line read from the file (it is like an INI but encrypted) might look like

AllowSysop = True

I know it is some RTTI look-a-like code that has to be made but I can't quite figure it out.

I think it would make it a bit easier for me if this was possible.

Hope the explanation is making sense

Trinitroglycerin answered 16/1, 2013 at 6:59 Comment(1)
All of your values are boolean?Dombrowski
F
19
implementation
uses TypInfo;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   if IsPublishedProp (Button1, 'Visible') then
    begin
      SetPropValue (Button1, 'Visible',false);
    end;

end;
Florid answered 16/1, 2013 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.