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 开发者_JAVA技巧anyone has used this function, and if so, how this function is meant to be used.
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)
精彩评论