I have types in distincts units with the same name and I have the unit name in a string. I need to access the specific type of this unit. How do I do that?
Example:
unit Unit1
type
TFooType = (
bar1,
bar2
);
then, I have another unit
unit Unit2
type
TFooType = (
foo1,
foo2,
foo3
);
And, somewhere in my code I have the a string variable "UnitName" with the value 'Unit1' within it and I want to access the Unit1's "TFooType" type by the variable.
I'm using Delphi 2007
Sorry for my bad english.
Thanks in advance.
The best you could do would be something like
if name='Unit1' then T := Unit1.TFooetc. But what can you do withTanyway? Since the enumerated types from the different units are different, it's hard to imagine being able to anything withT. In fact how would you even defineT? The only thing I could imagine would be possible would be to return the type info but I'm letting my imagination run wild now!