Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with "Variant" Data Type inside a Record

Status
Not open for further replies.

ddverne

Programmer
Dec 29, 2011
9
0
0
BR
Hi Guys,

I'm having some trouble when I'm trying to Initialize a constant record when one of the types is a "VARIANT" one.

For example:

This WORKS:

const
myRec : array [0..1] of record Num : integer; Str : string; end =
(
(Num: 100; Str: 'ABC'),
(Num: 200; Str: 'DEF')
);


But this don't

const
myRec : array [0..1] of record Num : integer; Str : string; Test : Variant end =
(
(Num: 100; Str: 'ABC'; Test : VarArrayCreate([0,1], varInteger)),
(Num: 200; Str: 'DEF')
);


In fact what I want to do is create an Array inside my Record for generic data type and length, it should be something like this:

const
myRec : array [0..1] of record Num : integer; Str : string; Test : Variant end =
(
(Num: 100; Str: 'ABC'; Test : Array[0..2] of Variant = ('a', 100, 33.33)),
(Num: 200; Str: 'DEF'; Test : Array[0..1] of Variant = ('b', 200))
);

Is this possible?

Thanks,

ddVerne.
 
Hi DjangMan,

In fact I could create a class etc. But I would like to try this without using objects, since it will be a constant and everything is already done, my only concern is about to using a data type which could store (pre-determined) array length of some type of data.

Let's forget about 'Variant' and think about Integers:

There is a way to do something like this?

const
myRec : array [0..1] of record Num : integer; Str : string; Test : SomeData end =
(
(Num: 100; Str: 'ABC'; Test : Array[0..2] of Integer = (1, 2, 3)),
(Num: 200; Str: 'DEF'; Test : Array[0..1] of Integer = (4, 5))
);

Or for example defining "Test as Pointer" and point to an array which was already initialized?

Like this:

const
Array1 : Array[0..2] of Integer(0,1,2);
Array2 : Array[0..1] of Integer(3,4);

myRec : array [0..1] of record Num : integer; Str : PInteger; Test : SomeData end =
(
(Num: 100; Str: 'ABC'; Test : @Array1),
(Num: 200; Str: 'DEF'; Test : @Array2)
);


I really appreciate any any help.

Thanks,

ddverne.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top