I search for some trick to realize something like this:
I search for some trick to realize something like this:
ISome = interface
function GetValueVar() : Variant;
procedure SetValueVar(aValue : Variant);
function GetValue(aIndex : Integer) : Variant;
procedure SetValue(aIndex : Integer; aValue : Variant);
// two props with the same name
property Value[aIndex : Integer] : Variant read GetValue write SetValue;
property Value : Variant read GetValueVar write SetValueVar;
end;
var
x : ISome;
begin
x.Value := 0;
// or if I needed in other case
x.Value[0] := 'string';
ISome = interface
function GetValueVar() : Variant;
procedure SetValueVar(aValue : Variant);
function GetValue(aIndex : Integer) : Variant;
procedure SetValue(aIndex : Integer; aValue : Variant);
// two props with the same name
property Value[aIndex : Integer] : Variant read GetValue write SetValue;
property Value : Variant read GetValueVar write SetValueVar;
end;
var
x : ISome;
begin
x.Value := 0;
// or if I needed in other case
x.Value[0] := 'string';
An ugly and brittle hack to work around the fact that records are value types and thus copied just to use a property in some ambiguous way.
ReplyDeleteWow, that's a shockingly bad idea. Swim with the current, not against it.
ReplyDeleteWhy not to use olevariant with single property ?
ReplyDeleteOleVariant could handle any type of data and has info about type that is actually handling e.g
TVarData(my property).vKind