LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure

Yup, my initial guess was correct.

What i described is what Frozen posts, do that instead.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 11 of 22
(922 Views)

wiebe@CARYA wrote:

That is scary. Don't do it like that!

 

 


Reminds me of a Matryoshka doll.

 

mcduff

Message 12 of 22
(922 Views)

@Frozen wrote:

Here is One way to avoid the nested case structures...

 

Frozen_0-1584974868702.png

 


Just to add a bit to this method:

You can display the number in the case structure as binary so you can more easily visualize which case it is that you are editing.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 13 of 22
(921 Views)

@billko wrote:

Just to add a bit to this method:

You can display the number in the case structure as binary so you can more easily visualize which case it is that you are editing.


Interesting! I've never thought about that you can change the Radix! 😄

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 14 of 22
(913 Views)

@Yamaeda wrote:

@billko wrote:

Just to add a bit to this method:

You can display the number in the case structure as binary so you can more easily visualize which case it is that you are editing.


Interesting! I've never thought about that you can change the Radix! 😄

/Y


I hope this makes up for the recent string of mini-faceplants that I've had lately.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 15 of 22
(894 Views)

@billko wrote:

Interesting! I've never thought about that you can change the Radix! 😄

/Y


I hope this makes up for the recent string of mini-faceplants that I've had lately.  😉


None i've reacted to, but some threads causes facepalms 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 16 of 22
(888 Views)

I'd suggest one more modification- put the "case processing" in a subVI. This will make it a million times easier to debug and is a million times more expandable if things change down the line for "what inputs match what case". Use an enum to identify cases. In your "main program", use one case structure with that enum as its input. Have one enum for each case and combine cases in your subVI. If your logic requires 16 different responses, have 16 responses, but if it just has 3 responses, include them there. For example, if your logic is "If no inputs are True, write 'Idle' to the screen." "If at least one input, but not all, are true, write 'Processing' to screen." "If all indicators are true, write 'Finished' to screen". You can code that up very easily in your subVI.

 

suggested code.png

 

process inputs.png

Message 17 of 22
(885 Views)

@Yamaeda wrote:

None i've reacted to, but some threads causes facepalms 🙂

/Y


Why isn't there a facepalm emoticon?

 

For now I'm using 😀🌴 (face + palm)...

Message 18 of 22
(877 Views)

@BertMcMahan wrote:

I'd suggest one more modification- put the "case processing" in a subVI. This will make it a million times easier to debug and is a million times more expandable if things change down the line for "what inputs match what case". 


If you have a proper grasp of binary numbers, that's not a million times easier. Maybe just a bit. It is a good idea to consider though.

 

Sorry, this just has to be said...

Spoiler
There are 10 types of people, those who understand binary and those who don't.
0 Kudos
Message 19 of 22
(874 Views)

wiebe@CARYA wrote:

@BertMcMahan wrote:

I'd suggest one more modification- put the "case processing" in a subVI. This will make it a million times easier to debug and is a million times more expandable if things change down the line for "what inputs match what case". 


If you have a proper grasp of binary numbers, that's not a million times easier. Maybe just a bit. It is a good idea to consider though.


Ehh.... I'd still want to separate responsibility, and it's always easy to get your endian-ness switched. Plus if this was me, I'd end up with some other condition I need to hit down the line ("ok if it's 1001 AND analog voltage is above 2.5 V, then do this, otherwise do this").

 

IMHO, if you don't actually need 16 cases but need to filter based on inputs, it's easier to have your truth table in a subVI rather than having each case be "0001..0100, 1010" etc. In my example above you would have three cases, 0000, 1111, and Default, which I agree isn't bad at all. It just comes when you need to combine random cases that it just gets neater (and takes less diagram space, and gives more room for comments) to just process it in a subVI.

 

And...

 

Spoiler
There are 10 kinds of people in this world. those who understand binary, those who don't, and those who didn't expect this joke to be in ternary 🙂
0 Kudos
Message 20 of 22
(867 Views)