LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

class with event refnum for the class illegal?

I was just toying around with a LVOOP implementation of a multiselect listbox control and I came across something I don't quite understand.

 

I know that a class A with another class A as a data member is illegal.  I understand this.

 

But a class A with a refnum to a user event of type A is illegal too in LV2011...  This seems too restrictive to me.  Is there a situation where this cannot be allowed or is the IDE just being a little too fussy.  I would like my objects to create and control their own events and this is kind of standing in my way of doing that.

 

Any answers appreciated.

 

Shane.

0 Kudos
Message 1 of 6
(2,679 Views)

Hi, Shane

 

The first thing I would try is to create a refnum to a user event of a General LV Object constant and then include it within your type A class. Then you can use "To More Specific Class" block to access to the object data.

 

Thanks

SK

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 2 of 6
(2,670 Views)

Think about it this way - you have the class definition. That's the platonic ideal. There's a single copy of that somewhere. Now, you add in that definition a reference which points to itself. The reference is null (although initially it might not be), but to resolve its data type, LV still has to go to that original copy, which still sends you into a cycle.

 

Maybe it's possible to break that cycle in the IDE (something like "stop the recursion if you encounter a class which has already been visited"), but it's possible that this isn't possible or that it's too complicated given existing code.


___________________
Try to take over the world!
0 Kudos
Message 3 of 6
(2,653 Views)

I have attached an example class which implements my workaround. Hope it helps 🙂

("UserEventRefnum.ctl is mistakenly included, but it is not used nor useful)

TailOfGon
Certified LabVIEW Architect 2013
Message 4 of 6
(2,647 Views)

OK It seems that I cant' do directly what I wanted.  I still want to be able to pass the data into and out of an event structure via dynamic event terminal so I have come accross another workaround.

 

I complete my class A without event refnums.  I then implement a child class B with my event-relevant code and data (Type A) and use this.

 

I haven't tried it yet, but sometimes I just wish things like this would work in LabVIEW.

 

Shane.

0 Kudos
Message 5 of 6
(2,634 Views)

But why does LV have to iterate the data type beyond what is already instantiated....  I see no reason why it shouldn't technically be possible.

 

Shane.

0 Kudos
Message 6 of 6
(2,633 Views)