03-02-2011 11:39 AM
Does a select function execute all code to know the input values for both inputs, even if i wire a FALSE constant to the selctor? (Can you avoid case structures with a select function?)
Solved! Go to Solution.
03-02-2011 12:34 PM
Yes. And no. LabVIEW is a dataflow language, not a procedural language. Thus, a function will not execute until all inputs that are wired have data on those wires. That said, the Select function has no code per se, so your question doesn't make much sense. Whatever code is on the block diagram to generate the data on the wire that's connected to the True part still has to execute because the Select function needs that data, regardless of whether the select input is true or false.
The Select function is not designed to avoid/replace case structures. If it did, there would be no need for a case structure. It has its use, just like the case structure. If you're trying to avoid the computation of something then it sounds to me like you really want a case structure.
03-02-2011 12:40 PM
Thank you, was just wondering whether I could use it for this, but in my program, it only has to execute one comparision extra, so it doesn't really matter.
03-02-2011 12:41 PM - edited 03-02-2011 12:42 PM
OK re-reading your question, does the "select function" execute all code to know the input values? The select function doesn't and as I suspect the optimizer probably shakes its little binary brain and goes, wonder why all the extraneous code was included if the answer (to which select) was already known. I think I'll just discard all the other stuff. Not sure, suspect if you run it with highlighting on (the debug "lightbulb") data will "flow" down both paths though.
Why do you care, why do you have a select if you know which one you want to select. If you don't want the code to be compiled in there is another structure that allows you to "comment out" code that you don't want (it can even be broken) called the "Diagram disable".
Yeah, what smecurio said !