LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to create a recursive cluster?

Solved!
Go to solution

I'm trying to create a clusterA with several string and numeric fields BUT additionally I need to include an array of clusterA variables. Is this even possible?

 

Is this possible with OO in LabVIEW86?

 

Thanks!

 

<<-N->>

0 Kudos
Message 1 of 5
(3,241 Views)
Solution
Accepted by topic author icastillejos

The direct answer to both questions is no. LV does not allow recursive data types.

 

That doesn't mean, however, that you can't do it entirely. You can do it, but you lose some type safety:

 

  • With LVOOP, you create an array of LV Object (or another class which A inherits from). You can now push your class into the array and take it out. You can use dynamic dispatch to operate on it or To More Specific Class to cast the elements you take out at run time to the correct class and then do whatever you need.
  • With a normal cluster, you should be able to do something similar by making the data type of the array a variant or a string and then flattening your clusters before pushing them into the array. This will most likely require more memory allocations and you're probably better off going the LVOOP route.

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

Or you can simply include a reference to the same data type as part of your cluster data, that should work too although I haven't tried it.

 

Required some extra work (as all the possibilities do) but if it's absolutely critical to have, then it might work.

 

Shane.

0 Kudos
Message 3 of 5
(3,216 Views)

You can create a clutser B which hold Cluster A and an array of cluster A ... but it'd be more efficient to somply have an array of cluster A and use the 1st as main. 🙂

 

/Y 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 5
(3,199 Views)

Thanks everyobdy for your prompt response!...

 

I'll try these approaches

 

<<-N->>

0 Kudos
Message 5 of 5
(3,174 Views)