1

Topic: TCustomVariant (varDecimal)

Faced a variant at which Vtype = 14.  this type does not support

//varDecimal = $000E; {vt_decimal 14} {UNSUPPORTED as of v6.x code base}

It wanted to write to it successor TCustomVariantType where to describe all manipulations with it. Ran into such lines

CMinVarType = $0100;
constructor TCustomVariantType. Create (RequestedVarType: TVarType);
var
LSlot, LWas, LNewLength, I: Integer;
begin
inherited Create;
MonitorEnter (LVarTypeSync);
try
LSlot: = RequestedVarType - CMinVarType;
if (LSlot <0) or (RequestedVarType <CFirstUserType) then
raise EVariantError. CreateFmt (SVarTypeOutOfRangeWithPrefix, [HexDisplayPrefix, RequestedVarType]);

For varDecimal LSlot will be less zero and there will be an exception.
Whether correctly I understand, what for varDecimal to make TCustomVariantType it is impossible? Or there are bypass ways?
Now, at the moment of obtaining of such variant it is caused VariantChangeType with  in minimum accessible type
Yours faithfully, Vasilisk

2

Re: TCustomVariant (varDecimal)

_Vasilisk _;
There not only business in the designer, there CMinVarType everywhere figures, and for varDecimal you TCustomVariantType will not redefine
But what for?
varDecimal it is processed as system

procedure TForm1.FormCreate (Sender: TObject);
var
V: Variant;
X: Double;
begin
TVarData (V).VType: = $000E;
TVarData (V).Reserved1: = 1;
TVarData (V).VInt64: = 1234;
X: = V;
Caption: = FloatToStr (X);
end;

3

Re: TCustomVariant (varDecimal)

By the way an integer part not Int64, and UInt64
And the sign is defined by high bit Reserved1

4

Re: TCustomVariant (varDecimal)

SOFT FOR YOU wrote:

varDecimal it is processed as system

If it was processed, I and a subject such did not lift

SOFT FOR YOU wrote:

By the way an integer part not Int64, and UInt64

By the way, an integer part it UInt96 (12 byte)

SOFT FOR YOU wrote:

And the sign is defined by high bit Reserved1

And still there is an accuracy. Generally, for correct access to fields, it is necessary TVarData to lead directly TDecimal

5

Re: TCustomVariant (varDecimal)

SOFT FOR YOU wrote:

By the way an integer part not Int64, and UInt64
And the sign is defined by high bit Reserved1

The code which I resulted above, does not work for you?
For me works. Windows 7, Delphi XE 8.
And accuracy in an example too is specified - 1 discharge.

6

Re: TCustomVariant (varDecimal)

[quote = _ Vasilisk _] By the way, an integer part it UInt96 (12 byte)

Yes, you are right, still it is necessary Reserved2 and Reserved3 to fill
Either RawData [1], or VLongs [0]