Var

ShowValue (v); However if you wrote:

This would cause a runtime error, complaining about a wrong variant to boolean conversion. Delphi 2009 changes this considerably. The two calls to ShowValue with a variant parameter simply refuse to compile, claiming that it cannot determine which of the two versions to call:

[DCC Error] E2251 Ambiguous overloaded call to 'ShowValue'

Related method: procedure TFormVariantOver.ShowValue(Integer);

Related method: procedure TFormVariantOver.ShowValue(string);

What's nice is that you see more details that in the past. In the error message pane you'll see an error with a plus sign that can be expanded to get further details:

Mes&ages b [DCC Error] VariantQver_MainForm,pas(69)i E2251 Ambiguous overloaded call to 'ShowValue'

VanantOver_MainForm.pas(28): Related method: procedure TFormVanantCiver.ShowValue(IntEger); VariantOver Main Form. DasfZ'il Related method procedure TFormVanantOver.ShowValuefEtrina):

Again, getting a compiler error (a detailed one in this case) is not that bad, as this gives you an option to recognize the potential issue and fix it by casting the variant to a specific type:

ShowValue (Integer(v)); ShowValue (string(v));

This code works in Delphi 2009 and works better in Delphi 2007 as well, as you won't get the runtime variant conversion error any more.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment