07-06-2009 02:25 PM
I have a Labview class that is a collection of objects from another class (c1), held within an array. This is similar to a Visual Basic Collection with a method of indexing and adding to the collection/array. If I understand Labview classes correctly, Labview objects are passed by value and not by reference. So, in my example with a collection of objects, if I need to update one of the attributes within one of the objects (o1), I'll need to:
1) index into the array;
2) extract the object (which make a copy);
3) update the attribute within the object; then
4) insert the object back into the array, (over-writing the original object).
If the class associated with object (o1) has 40-50 attributes, it seems inefficient to make a copy of the entire object just to update one attribute. In C/C++, I would just use a pointer to the instance and update it directly.
My questions is:
1) what is an efficient way to update the attribute of an object held within an Labview Array?
(or is there a better way to do this).
2) where can I find references that compare/contrast labview programs to C/C++,
so that I might better understand how to code efficiently in Labview.
07-06-2009 02:36 PM
If you have 8.5 or later, your best bet for minimizing copies is the inplace structure, and it has the added advantage of producing cleaner code for something like this.
As for a comparison, you should start by reading this and this. Also, the LAVA forums have a lot of good discussions about LVOOP which you will want to look through.
07-06-2009 02:56 PM
Yes, I'm using Labview 8.6.1. I've seen both of the references that you indicated, but I'll have to re-read them in more detail. Also, I see that LAVA is back online, so that will be a good resource.
Regarding the "inplace structure", thanks, I didn't know about that and it looks like a good suggestion. It should fit as a new method within my collection class.
http://zone.ni.com/devzone/cda/tut/p/id/6211
http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/in_place_element/
http://thinkinging.com/2008/01/29/in-place-element-strucure-saves-time-and-prevents-bugs/