LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

select function

Solved!
Go to solution

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?)

0 Kudos
Message 1 of 4
(4,055 Views)
Solution
Accepted by topic author Raggie

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.

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

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.

0 Kudos
Message 3 of 4
(4,039 Views)

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 !

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 4
(4,037 Views)