For example, create a new application, double-click the Form1 object to
create a FormCreate() event handler and add the following line:
ShowMessage(IntToStr(VarType(1)));
Under Delphi 5, this shows '3' which corresponds to varInteger. However,
under Delphi 6 (with or without Update Pack 1) '17' is shown which
corresponds to varByte. The same problem occurs if you pass an enumerated
type.
We discovered this problem while using TopGrid 2.20 with Delphi 6. Trying to
assign a Variant parameter to cbChecked (one of the TCheckBoxState
enumeration constants) ends up raising an exception because the TopGrid code
depends on the result of a call to VarType().
This means any code which depends on the result of a call to VarType() when
a constant or enumerated type is passed, will fail under Delphi 6. It could
be argued that code should not have such a dependency since the 'type' of an
enumeration constant should be considered undefined. However, if this change
was made, it would have been nice if it was documented.
We have submitted this as a bug to Borland and are awaiting a response. Has
anyone else come across this problem?
Brian Drennan
Brian Drennan wrote:
>
>
> We have submitted this as a bug to Borland and are awaiting a response. Has
> anyone else come across this problem?
>
This is not a bug. Variants were totally rewritten under D6. Unlike D5
Variants, the D6 Variants has a much higher granularity. So the VarType of 1 is
a byte because this is the smallest granularity that 1 fits in. The D5 Variants
the smallest granularity is an integer.
You can find Eddie Churchill's explanation at
http://www.mers.com/MERLIST/BORLAND/PUBLIC/DELPHI/UPGRADE/2460.HTML
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
The fool escaped from paradise will look over his shoulder and cry
Sit and chew on daffodils and struggle to answer why?
As you grow up and leave the playground
Where you kissed your Prince and found your frog
Remember the jester that showed you tears, the script for tears. (Fish)
Fair enough. Though it would have been nice to have been documented
somewhere- anywhere!
> http://www.mers.com/MERLIST/BORLAND/PUBLIC/DELPHI/UPGRADE/2460.HTML
A most useful link. Thanks for your reply.
Brian Drennan
> ShowMessage(IntToStr(VarType(1)));
> Under Delphi 5, this shows '3' which corresponds to varInteger. However,
under Delphi 6 (with or without Update Pack 1) '17' is shown which
corresponds to varByte.
Brian, Different, yes; but I would consider that they both are correct.and
thus neither should be classified as a bug. If there is a problem, I
suggest that it may be with routines that do not correctly interprete the
variant types. Regards, JohnH