LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Specify variant type in class attribute for a lookup table


@Yamaeda wrote:

I'm not quite sure of what you're trying to achieve, but having your Alarms as attributes is simple enough. You won't be able to see what type they are during coding (as you're basically working with void*) but can control it. 

Set a variant attribute with a Name and the alarm as property, Get the named property and convert via Variant to data, as you always have to do with variants.

/Y


yes it is what I wanted to do, but it doesn't seem possible to do that in the class private data (unless it is ?)

0 Kudos
Message 11 of 13
(331 Views)

@YannickB wrote:

@Yamaeda wrote:

I'm not quite sure of what you're trying to achieve, but having your Alarms as attributes is simple enough. You won't be able to see what type they are during coding (as you're basically working with void*) but can control it. 

Set a variant attribute with a Name and the alarm as property, Get the named property and convert via Variant to data, as you always have to do with variants.

/Y


yes it is what I wanted to do, but it doesn't seem possible to do that in the class private data (unless it is ?)


It's possible, but the variant attributes won't be strong typed. That is what you seem to want.

 

So the attributes in the class's data private variant could contain anything. But if you don't let it add anything but your type (e.g. give the get and set function the type def as input), it won't have anything else but the type. It's simply not possible to reflect that in the variant's data type.

Message 12 of 13
(326 Views)

@YannickB wrote:

@Yamaeda wrote:

I'm not quite sure of what you're trying to achieve, but having your Alarms as attributes is simple enough. You won't be able to see what type they are during coding (as you're basically working with void*) but can control it. 

Set a variant attribute with a Name and the alarm as property, Get the named property and convert via Variant to data, as you always have to do with variants.

/Y


yes it is what I wanted to do, but it doesn't seem possible to do that in the class private data (unless it is ?)


Void* can never be decided during coding in any language, private data or not. The above suggestion to create a Get/Set function with a cluster input and a fixed output conversion is the way to go. If you want it strongly typed, you should have e.g. an array of clusters, with the Name and your cluster as cluster items. You can go the named queue route also, but you'll probably start creating problems for yourself on the "strongly typed altar".

Named Types.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 13 of 13
(323 Views)