LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to exit a TRUE FALSE case with a variable without having to specify the False case?

Solved!
Go to solution

Dear Labview community,

 

I got a question that I have frequently encountered, I wonder what is the best solution to this.

 

Often I need to do an operation to something if a condition is true and there is nothing to do if it is false.

 

But if I wire that variable.. as in dataflow..then I need to specify what is the false case value. But often I do not need a false case value and it should not be zero either ( as in default if unwired)  for example..

 

What I tried is simply use a property node of my variable and a sequence as shown in the jpg. Attached VI.

 

Is there a better way of doing this?

 

Additional question:

To maintain dataflow with a variable, sometimes I used a similar sequence + error control attached to the property node or error in.

 

Is there a more elegant way instead of using a sequence + an error control to maintain dataflow?

 

Bypassing TF case.JPG

 

 

Download All
0 Kudos
Message 1 of 5
(2,916 Views)
Solution
Accepted by topic author rajiv85

As a general rule, it's best to have the controls on the outside of the case structure.

Case Pass Through.png

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Message 2 of 5
(2,901 Views)

Ahhhhh!! Thank you!!! 👍👍

0 Kudos
Message 3 of 5
(2,897 Views)

And since you're fairly new and learning, here's a little bit of the *why*.

 

One little bit of "tribal knowledge" us old-timers carry is that the LabVIEW compiler is able to do more efficient optimizations when controls and indicators are placed on the base block diagram, not inside any structures.   I think this is especially true if those controls or indicators are assigned as wire-able terminals for the vi.

    It's a fine-tuning detail, which isn't really crucial in a lot of apps, but it isn't bad to learn about and develop good habits early.

 

So while we're on the topic of fine-tuning, there's another small mod worth considering.  As shown, the False case will read a value from the control and then write the same value back to it via local variable.  It's essentially a no-op.  You might consider coding it that way to make the no-op nature clear.   See the snippet below.

    As for the rule of thumb about putting controls and indicators on the base diagram instead of inside structures, I don't think it applies to local variables, at least not nearly as strongly.

 

 

-Kevin P

 

conditional increment.png

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? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 5
(2,866 Views)

Thank you very much Kevin for the tips! I got some valuable tips from you many times before on other posts. As soon as I have time I will try to search your previous posts on the forum to learn more from you 😉

 

 

 

 

0 Kudos
Message 5 of 5
(2,846 Views)