06-30-2012 03:44 PM
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.
06-30-2012 06:27 PM - edited 06-30-2012 06:28 PM
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
06-30-2012 10:13 PM
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.
07-01-2012 12:05 AM - edited 07-01-2012 12:06 AM
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)
07-01-2012 09:44 AM
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.
07-01-2012 09:51 AM
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.