Reputation: 47
I am trying to convert Delphi2005 code to Delphi Tokyo 10.2.3 code.
The function VarType
is no longer recognized.
I need the function VarType
to determine the basic type of a variant variable. In general I find, according to many postings, that it should be in the unit System.Variants
. However, if I search e.g. in:
It is not in this unit. Furthermore, I cannot find the unit variants, only a unit variant. However, using the unit variant I get a runtime error:
Record, object or class type necessary
. So this doesn't work.
if (System.Variant.VarType(Value) and varTypeMask) =
System.Variant.varString then // VarType(Value) unbekannt
begin
TByte8Array(PRecFORMULA3(PBuf).Value)[0] := 0;
end;
Anyway I don't find VarType
in System.variant. Does variants not exist anymore?
Can anyone help me?
Upvotes: 0
Views: 1091
Reputation: 595467
The documentation you linked to is quite old. It is for Delphi 2009, which predates the introduction of Unit Scope Names. But even in that old documentation, VarType()
is documented as being in the Variants
unit (not in the Variant
unit, which does not exist).
Unit Scope Names, like System
, were added to RTL/VCL unit names in XE2 (thus, the Variants
unit became System.Variants
).
Embarcadero's newer DocWiki, which replaces the old Docs site, clearly shows that the VarType()
function is indeed located in the System.Variants
unit.
Make sure that either:
you have System.Variants
in your uses
clause:
uses
..., System.Variants;
you have System
in your project's list of Unit Scope Names, and then you can use Variants
in your uses
clause:
uses
..., Variants;
Either way, you can then use VarType()
as expected, without having to fully qualify it:
if (VarType(Value) and varTypeMask) = varString then
begin
TByte8Array(PRecFORMULA3(PBuf).Value)[0] := 0;
end;
Upvotes: 1