LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Easy way to create parent class from child class? (yes, backwards from norm)

Is there a way to create parent class from child class? (yes, backwards from norm). I created a class, lets say Triangle. Some time later, much later, when refactoring my code, I had a need for a Square class. Now at this point it's obvious I should have created a Shape parent class and derived the child classes Triangle and Square from it.  But this is a very simplified example which looks rather obvious that I should have created a Shape class from the start... but hindsight is 20/20 they say, and in my more specific case you couldn't have even imagined that I would have needed to.. and here I am.  Thus my question: is there and easy (any?) way to create parent class from child class? Note that I do have and am using LAVA- Create Child Class Project Tool, so that make the task easier.

https://lavag.org/topic/15390-create-child-class-project-tool/

^TeraTech.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Check out this lengthy post of mostly complaints)
0 Kudos
Message 1 of 4
(2,584 Views)

With that premade tool it's probably not possible.

 

However, if you have a project window open, right-click a class file and go to Properties, then the Interitance tab, then click Change Inheritance, you can change the parent class to any class in memory so long as it isn't currently defined as a child of the class you're editing.

 

The actual act of making the classes work is up to you, with all the override VIs set up just right.  If you have both classes open in the same project you can move VIs from one to the other, though you may have issues with accessing private class data if you don't move that around properly too as well as its accessors.

Message 2 of 4
(2,554 Views)

If in the project, right-click on your class and select "Save As".  You will be given an option to duplicate the class.  Now you have to go in and update all of your VIs from there.  But that will get you around half way there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(2,481 Views)

@crossrulz wrote:

If in the project, right-click on your class and select "Save As".  You will be given an option to duplicate the class.  Now you have to go in and update all of your VIs from there.  But that will get you around half way there.


That's how I do it. It's a bit laborious, but he, more motivation for making a design.

0 Kudos
Message 4 of 4
(2,467 Views)