Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 May : Invalid Variant Type when initializing Variant
| Subject: | Invalid Variant Type when initializing Variant |
| Posted by: | "Isaac Alexander" (isaanospamc@gopronospamcura.com) |
| Date: | Mon, 30 May 2005 15:30:05 |
I am using D7.1. I am working with some maintenance code that randomly
gives an "Invalid Variant Type" exception (EVariantBadVarTypeError). I have
tracked it down the following code.
TSearchType = record
Cache : Boolean;
Value : Variant;
Key : Longint;
Tree : TSortNode;
end;
TSearchTypeArray = array [0..100000] of TSearchType;
PSearchTypeArray = ^TSearchTypeArray;
TMyClass = class
private
SearchTable : PSearchTypeArray;
NumItems : Longint;
MaxedLimit : Boolean;
public
constructor Create(size : Longint);
end
constructor TMyClass.Create(size : Longint);
var
i : Longint;
begin
inherited Create;
// Allocate the Search table entries.
NumItems := size;
GetMem(SearchTable, NumItems * SizeOf(TSearchType));
// Initialize the Search table entries to Unassigned.
for i := 0 to NumItems - 1 do
begin
SearchTable^[i].Value := Unassigned; // error randomly occurs on this
line
SearchTable^[i].Cache:=false;
SearchTable^[i].tree:=NIL;
end;
end;
I was under the impression that I should only get this error if I try to
assign a normal datatype to an unassigned variant.
Any ideas?