1

Topic: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Good afternoon!
In procedure I work with COM-obktom which returns me an OLEVariant-variable (VarArray, but it is not important).
Procedure fulfills completely, to the last line. And further the exception "Invalid variant operation" takes off

procedure TMyForm. Button1Click (Sender: TObject);
var
vArr: OLEVariant;
begin
FCOMObject. CallSomeProcedure (vArr);
...
end;

And  stops here:

//unit Variants
procedure VarClearRare (var V: TVarData);
var
LHandler: TCustomVariantType;
begin
//let CORBA deal with its own type
if V.VType = varAny then
ClearAnyProc (V)
//ok, finally is it a custom variant type?
else if FindCustomVariantType (V.VType, LHandler) then
LHandler. Clear (V)
else
==> VarInvalidOp;
end;

[spoiler here contents of a variable "V"]

V.VType: 22,
V.VBytes: (0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 248, 51, 30, 0)

And such constant for VType = 22 ($0016) is not present

{Variant type codes (wtypes.h)}
varEmpty = $0000; {vt_empty}
varNull = $0001; {vt_null}
varSmallint = $0002; {vt_i2}
varInteger = $0003; {vt_i4}
varSingle = $0004; {vt_r4}
varDouble = $0005; {vt_r8}
varCurrency = $0006; {vt_cy}
varDate = $0007; {vt_date}
varOleStr = $0008; {vt_bstr}
varDispatch = $0009; {vt_dispatch}
varError = $000A; {vt_error}
varBoolean = $000B; {vt_bool}
varVariant = $000C; {vt_variant}
varUnknown = $000D; {vt_unknown}
//varDecimal = $000E; {vt_decimal} {UNSUPPORTED}
{undefined $0f} {UNSUPPORTED}
varShortInt = $0010; {vt_i1}
varByte = $0011; {vt_ui1}
varWord = $0012; {vt_ui2}
varLongWord = $0013; {vt_ui4}
varInt64 = $0014; {vt_i8}
//varWord64 = $0015; {vt_ui8} {UNSUPPORTED}
{if adding new items, update Variants' varLast, BaseTypeMap and OpTypeMap}
varStrArg = $0048; {vt_clsid}
varString = $0100; {Pascal string; not OLE compatible}
varAny = $0101; {Corba any}
varTypeMask = $0FFF;
varArray = $2000;
varByRef = $4000;

[/spoiler]
Decided to try to expose forcedly a variable in Unassigned.

procedure TMyForm. Button1Click (Sender: TObject);
var
vArr: OLEVariant;
begin
FCOMObject. CallSomeProcedure (vArr);
...
>>> vArr: = Unassigned; <<<
end;

Does not help.
But the most interesting if to compile on other computer helped (everywhere Delphi 6, truth there Update Pack 1, and at me Update Pack 2),
Help! There are ideas what to check up/adjust/tighten up?

2

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Simeon wrote:

Is ideas what to check up/adjust/tighten up?

Different clods-objects (versions)?

3

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

wadman wrote:

Different clods-objects (versions)?

Clods-objects of one version.
If I will compile on that computer and I will bring EXE-shnik on mine too normally fulfills.

4

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

$16 = vt_int and special cleaning does not demand.
Look that there it is caused to VarClearRare.

5

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Made  to check up the assumption that Delphi cannot define a variant-type. Whether Mahlo where there  specifies, can is wrong smile

//instead of vArr: = Unassigned;
TVarData (vArr).VType: = varNull;

Exception disappeared, we go further.
GunSmoker,
Thanks, now I will look

6

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Generally strange : different Variants.pas in Delphi mine and on that computer, at me is not present VarClearRare smile
I  showed break point from that computer, at me it is not defined.

7

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Transferred Variants.pas from that computer on the and supposed in a folder with the project and all fulfilled without Exception'a.
What now advise?

8

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Kroik Simeon> Procedure fulfills completely, to the last line.
And if variable not local, but global?
Also what happens if manually to cause VarClear?

9

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Kroik Simeon> That now advise?
Not to skip under versions smile
P.S. In old versions variants changed almost in each version -
That function from one unit moves to another, still that. :-)

10

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Someone's playful pens rummaged in Delphi? Because VarClearRare in raws Delphi 6 generally is not present (I checked up).

11

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Rustam wrote:

And if variable not local, but global?

"Invalid variant operation" takes off then at program termination

Rustam wrote:

Also what happens if manually to cause VarClear?

The same exception takes off

12

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

GunSmoker wrote:

Someone's playful pens rummaged in Delphi? Because VarClearRare in raws Delphi 6 generally is not present (I checked up).

In Delphi 6 + Update Pack 1 is
In Delphi 6 + Update Pack 2 (at me) again is not present

13

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Is not present such in Delphi 5. And I too looked at it.

14

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Key difference:

wrote:

finally let the OS attempt to deal with it

15

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Kroik Simeon> in Delphi 6 + Update Pack 1 is
> In Delphi 6 + Update Pack 2 (at me) again is not present
It seemed to me, at you , .

16

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

P.S. In the seven is not present, though VarClearDeep contains a code part, yes.

17

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Questions
Than potentially these two dirty variants can threaten?
1) if to leave this ?
//instead of vArr: = Unassigned;
TVarData (vArr).VType: = varNull;
2) If to change Variants.pas for other version, and only for this project

18

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Simeon wrote:

Than potentially these two dirty variants can threaten?
1) if to leave this ?
//instead of vArr: = Unassigned;
TVarData (vArr).VType: = varNull

leak if inside is to that to flow away

19

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

So works?

procedure TMyForm. Button1Click (Sender: TObject);
var
vArr: OLEVariant;
begin
FCOMObject. CallSomeProcedure (vArr);
end;

If yes search where you in

Simeon wrote:

...

you spoil storage

20

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

_Vasilisk _,
Unfortunately, so too an error.

21

Re: How to win "Invalid variant operation" at resetting to zero of the variable received from COM-obek

Simeon wrote:

unfortunately, so too an error.

If Simeon]

 is returned [quote=
V.VType: 22;

That you in any way will not process this value. It is unknown type and it is not known neither as with it to work nor how to read value, how to clear. It is natural garbage