Question

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.

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top