Type
TMyOption = (option1, option2, option3, option4);
TMyOptions = set of TMyOption;
function NumericToMyOptions(n: integer): TMyOptions;
var
Op: TMyOption;
begin
Result:= [];
for Op:= Low(TMyOption) to High(TMyOption) do
if n and (1 shl ord(Op)) > 0 then Include(Result, Op);
end;
procedure TForm1.W3Button9Click(Sender: TObject);
var Options : TMyOptions;
begin
Options := NumericToMyOptions(2);
asm console.log(@Options) end;
Options := [option1, option2, option3]; // 2^0 + 2^1 + 2^2
asm console.log(@Options) end;
end;
|