In variants.pas, there is several VarIsXXX( )-functions for type-checking a variant. There is no VarIsBoolean( ), though.
What's your preferred way of checking if a variant is of type boolean?
In variants.pas, there is several VarIsXXX( )-functions for type-checking a variant. There is no VarIsBoolean( ), though.
What's your preferred way of checking if a variant is of type boolean?
Try
varIsType(v, varBoolean);
It is easy then to write your own VarIsBoolean function
function VarIsBoolean(const V: Variant): Boolean;
begin
result := varIsType(v, varBoolean);
end;
Unfortunately when converting a variant to a boolean, the Delphi rtl first tries boolean and after that tries integer. Thus the error "Cannot convert variant xxx to integer" when you are actually converting a null variant to a boolean.