Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the VarIsEmpty and VarIsEmptyParam functions

Working in Delphi7 just now, I noticed that not only a VarIsEmpty function exists, but also a VarIsEmptyParam.

Since the help of Delphi does not give much explanation:

VarIsEmptyParam returns true if the given variant represents an unassigned optional parameter.

If the variant contains any other value, the function result is false.

I was just wondering if anyone has used this function, and if so, how this function is meant to be used.

like image 433
Edelcom Avatar asked Mar 08 '10 13:03

Edelcom


1 Answers

In COM it is possible to have optional parameters in a method call at any position, while in Delphi this is only possible at the end. So if you want to omit the parameter you can write EmptyParam instead. EmptyParam is a global variable initialized with the correct values.

Now when you are implementing a COM interface you have to deal with these optional parameters, too. The way to find out these omitted parameters is VarIsEmptyParam.

Note that even an empty variant given as a parameter yields VarIsEmptyParam = false, because the param is not omitted. It is just empty, but it is there.

So normally there is:

VarIsEmpty(v) ==> not VarIsEmptyParam(v)

and

VarIsEmptyParam(v) ==> not VarIsEmpty(v)
like image 172
Uwe Raabe Avatar answered Oct 07 '22 00:10

Uwe Raabe