LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure

Solved!
Go to solution

Hello, 

 

In the attached VI, I have taken 'String element' from an array and fed it to case selector. But, case selector isn't working. (executing only the default case)

 

Please explain what's going wrong. 

 

Thanks. 

0 Kudos
Message 1 of 13
(4,019 Views)
Solution
Accepted by topic author Ganny

See those unconnected wires that you use on the output of most events? Since it is not connected it will have the "default value" of the underlying datatype (i.e. on string an empty string).

 

If you don't understand this, see for yourself what is going on and watch your block diagram in highlight execution mode.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 2 of 13
(4,009 Views)
Solution
Accepted by topic author Ganny

Your problem is the unwired output tunnels from your Event Structure.  I highly recommend you turn off the Use Default If Unwired option for all of your output tunnels.  You just wire the values straight through if you are not updating the values.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 13
(4,008 Views)
Solution
Accepted by topic author Ganny

@crossrulz wrote:

...  I highly recommend you turn off the Use Default If Unwired option for all of your output tunnels. ...


Excellent advice that I recommend myself. The option to use the default if not wired may reduce frustration with novice developers that may not be able to figure why the VI is broken, but they can and will introduce a challenge when trying to figure out why applications are not operating correctly, as is the case in this thread.

 

Spoiler

 

The first time I encountered the reprecussions of the use default if not wired was an application that worked great in every regard save one out of the blue situation where when the phase of the moon was wrong and the cat was swung the wrong way (yes a cat was harmed in the trouble shooting of that code I have to admit) an unwanted result occurred. it was a file reference that was not wired through a Event Structure. Took a while to figure what phase of the moon was required to be able to reproduce the problem.

 

 

 

Once burned, twice weary.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 13
(3,990 Views)

@Ben wrote:

@crossrulz wrote:

...  I highly recommend you turn off the Use Default If Unwired option for all of your output tunnels. ...


Excellent advice that I recommend myself. The option to use the default if not wired may reduce frustration with novice developers that may not be able to figure why the VI is broken, but they can and will introduce a challenge when trying to figure out why applications are not operating correctly, as is the case in this thread.


Just to complete the thought:  They only time I use the Use Default If Unwired on a regular basis is for the stop condition.  This works because only 1 case should be stopping the loop and the default for a Boolean is FALSE.  It is just a little convenient to only have to wire up the constant in 1 case.  There are exceptions, but very rare.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 13
(3,965 Views)

@crossrulz wrote:

@Ben wrote:

@crossrulz wrote:

...  I highly recommend you turn off the Use Default If Unwired option for all of your output tunnels. ...


Excellent advice that I recommend myself. The option to use the default if not wired may reduce frustration with novice developers that may not be able to figure why the VI is broken, but they can and will introduce a challenge when trying to figure out why applications are not operating correctly, as is the case in this thread.


Just to complete the thought:  They only time I use the Use Default If Unwired on a regular basis is for the stop condition.  This works because only 1 case should be stopping the loop and the default for a Boolean is FALSE.  It is just a little convenient to only have to wire up the constant in 1 case.  There are exceptions, but very rare.


I use it often with Booleans but NOT as the default. It makes ME think what I want to pass along. When used as the default it could set me up for a problem that may not show up with testing every variation.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 13
(3,962 Views)

Hello, 

Thanks Ben and CrossRulz. Now I learnt what was happening. I got it working.

 

Cheers. 

 

 

0 Kudos
Message 7 of 13
(3,954 Views)

Just to put a bow on it...

 

There's a somewhat new-ish feature (at least my *awareness* of it is new-ish) that's sometimes really helpful.  You can right click a right-hand-side tunnel and assigne a "linked input tunnel".  There's even an option to auto-wire the unwired cases.

 

This pays off nicely when you have shift registers on your enclosing loop, and most of the cases just pass the value straight through.

 

 

-Kevin P

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).
Message 8 of 13
(3,930 Views)

Hey there, 

 

While I'm trying to add some more features to the calculator like adding another display that shows the operands. I'm partially successful. For instance, if I want to add 3 and 4, I want to display "3+4". I could manage displaying "3+" by concatenating strings but couldn't get the '4'.

 

Any suggestion on how I can accomplish it?  

 

Thanks

0 Kudos
Message 9 of 13
(3,912 Views)

Kevin_Price wrote:

There's a somewhat new-ish feature (at least my *awareness* of it is new-ish) that's sometimes really helpful.  You can right click a right-hand-side tunnel and assigne a "linked input tunnel".  There's even an option to auto-wire the unwired cases.


Linked Tunnels was one of my favorite features when it came out back in LabVIEW 8.6.  I consider them a must for state machines.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 13
(3,911 Views)