Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Delphi can a string be converted to a set

Tags:

string

set

delphi

For instance

Font.Style = StringToSet('[fsBold, fsUnderline]');

of course there would need to be some typeinfo stuff in there, but you get the idea. I'm using Delphi 2007.

like image 944
Alister Avatar asked Jun 14 '11 23:06

Alister


Video Answer


1 Answers

check this code, is not exactly the same syntax which you propose , but works setting the value of a set from a string.

uses
 TypInfo;

procedure StringToSet(Const Values,AProperty:string;Instance: TObject);
begin
  if Assigned(GetPropInfo(Instance.ClassInfo, AProperty)) then
     SetSetProp(Instance,AProperty,Values);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  StringToSet('[fsBold, fsUnderline, fsStrikeOut]','Style',Label1.Font);
end;
like image 138
RRUZ Avatar answered Oct 11 '22 20:10

RRUZ