LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code Improvement? (Picture included...which is better?)

Hi Guy,

I'm working on improving a piece of code that uses a reference from another VI, feeds into a loop that creates a new reference to a specific control in that VI, and passes its value from that VI to this one. There are 16 controls that need to be read and updated so long as the program is ran. (threw a 200mS wait in between iterations).

The current method works...Which is a sequence structure of 16 frames that repeats.  I've always thought of FOR loops as the method of consolidating repeated code though.  Given the attached picture....do you think this is a good way to go?  Its not really "messy" using the sequence when stacked, its just some code is hidden..which isn't a big deal for this application.  What do you think, worth it?

If so, that brings up 1 other question.  Not every value is the same data type, which is what made that so easy before.  How would you compensate for that?  Another auto-indexing array of data types feeding the Variant to Data function?  Better way to do it?

See picture for notes!

Thanks much!
LV7.1, LV8.5, LV2014/15/16
0 Kudos
Message 1 of 5
(2,825 Views)

In this Nugget I talk about handling a variety of control refence issues.

Please take a look at that Nugget for some ideas.

As illustrated in the Nugget, I prefer to handle things in a loop.

The multi-frame sequence structure that is generally shunned.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(2,817 Views)
Are there any performance differences between the two?

I've been working on it since that post and now have a cluster of types that will auto-index into the "type" terminal of the "Variant to Data" Function. 

I'm getting close to having it working...but if they perform identically...is there justification for me to do this?
LV7.1, LV8.5, LV2014/15/16
0 Kudos
Message 3 of 5
(2,814 Views)
You can at least have improved readability and maintainability.  Not to mention scalability -- a lot easier to add and remove if you have it formatted as a list going into a For loop.
0 Kudos
Message 4 of 5
(2,805 Views)

The performance difference should be insignificant.  Generally speaking the big code is usually a little faster than the smaller (here smaller is the For Loop).

Personally i prefer the For Loop method. It is a matter of coding style and not speed.



Message Edited by Pnt on 03-13-2008 05:01 PM
0 Kudos
Message 5 of 5
(2,798 Views)