LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

8 cases ??

If I have a set of data need to be processed, and they are totally 8 cases I need to determine.
Say if:
Value if 1~5 need to be added 2, 8~19 need to be added 1, 25~37 need to be added 4 ........
Is putting 4 Case Structure  together the only way I can do ??
 
 
 
0 Kudos
Message 1 of 10
(3,861 Views)
Make a case structure (integer type) where the cases are "1...5", "8...19", "25...37" and put the approperate code inside of the case. Note the the case selector is also a pass through node so you can use the value insied of the case structure.  Make a nonsense value the default case to capture error (bad values)
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 10
(3,815 Views)
No, there are better ways,

One is defining an array which contains the required numbers to be added at the right index.  Your example would have index 1,2,3,4,5 all with the value 2, 8,9,10...19 with the value 1 and so on.

Then you can use the number you're processing to index the array and add the resulting number.  This has the advantage that you can re-define the array at run-time.

Alternatively, you can use a single case structure with the number wired directly, and the case selector set to different ranges where the required operation is carried out in the respective case.  This is less flexible.

These are just twqo examples which have occurred to me, there's probably lots of other ways too.  4 CASE structures isn't the best way anyhow.

Hope this helps

Shane.
PS in the pciture, please ignore the wrong positioning of the label <--8.  It should be lower down, but I hope you get the idea.

Message Edited by shoneill on 02-23-2006 04:58 PM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 3 of 10
(3,816 Views)
I am not sure if I completely understand the question but you could have 1 case structure with a lot of differnet cases.
 
Take a look at the attached.
 
Wow looks like we all got it at about the same time. 
 
Let us know if these are not what you where looking for.

Message Edited by Evan on 02-23-2006 09:59 AM

Message 4 of 10
(3,813 Views)
What I described is version 2 of the previous post. 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 5 of 10
(3,810 Views)
You dont have use a boolean to wire it to your case structure.
Instead wire your number to it and determine the cases like in the added picture. 

Message 6 of 10
(3,804 Views)
By no means, you need only one case structure with multiple cases: wire your value directly to the case input, then define a case for each range.
For example, range 1~5 can be written as 1..5 in the case value box (I mean the upper box with small arrows). If your values are not integers, though, you should be very careful; generally, it is wise to reduce non-integer values to integers before wiring to the case structure input. Also, be careful to manage the default case properly.
Hope this helps.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 7 of 10
(3,803 Views)

Dawei schreef:

> If I have a set of data need to be processed, and they are totally 8 cases I need to determine.
> Say if:
> Value if 1~5 need to be added 2, 8~19&nbsp;need to be added 1, 25~37 need to be added 4 ........
> Is putting 4&nbsp;Case Structure&nbsp; together the only way&nbsp;I can do&nbsp;??
> &nbsp;
> &nbsp;
> &nbsp;

Well, why don't you connect this value to the case structure. Then you
can add as many cases to that structure as you want. So you would need
only one case structure, with 8 different cases, so not True/False, but
1-5/8-19/25-37 etc.

Does that solve your problem?

Laurent

Message 8 of 10
(3,792 Views)

Wow....

Thank you guys, so sorry to ask such a simple question.

This is exactly what I was asking.

0 Kudos
Message 9 of 10
(3,773 Views)
One additional comment about the case structure for working with handling discrete events, I find using a enum saved as a typedef to be a great pattern for labview architectures.  Also the case structure can adapt to an error cluster to seperate error and non error conditions.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 10 of 10
(3,737 Views)