LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use a Case Structure with Strings?

I need to use a string list to set up a set of cases to be performed. Is it possible to tell a single case structure to do "a, b, c, and d, but not e or f" or "do a, c, d, and f, but not b or e" etc... when you use a string containing the cases to be used?
0 Kudos
Message 1 of 7
(5,598 Views)
It is very simple. You can separate the strings for each case by putting the strings in double inverted commas (") and separete them by commas. In your first example create a case with - "a", "b", "c", "d" - and another case with "e" and another with "f" and one with default.
Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 2 of 7
(5,598 Views)
So how many cases would I need to cover every possible combination of a, b, c, d, e, and f? Because I don't know which combination I'll need at any given time... I am not going to make a case for a, a case for a, b, a case for a, b, c, a case for a, c, etc... because it is far too time consuming. Would it be necessary to have a seperate case for each combination?
0 Kudos
Message 3 of 7
(5,598 Views)
That all depends upon what is covered by the "etc" rules of your initial
question. You have not provided enough detail for an answer. If you have a
"word" string, that is, a string containing, for example "bad" and you
want to know whether or not it passes your test, you could first pop the "b" off
the top of the string, process it, and pass "ad" and the current state on to the
next step of your state machine. Have you designed the state machine, or set down
all the rules for your process on paper yet?

Les.Hammer@CompleteTest.com
0 Kudos
Message 4 of 7
(5,598 Views)
I just need to know if case structures can activate multiple cases at once, really. Ideally, I would have a case for a, a case for b, a case for c, etc... and those letters which appear in the string would be the executed cases.
0 Kudos
Message 5 of 7
(5,598 Views)
Blackavar,

A case structure will only execute a single case at a time. If you want to have multiple cases execute in parallel, then you would need to have multiple copies of the case structure and split the string apart and wire them to all of the needed case structures.

This could be done with reentrant subVIs to run truely in parallel. Anther method would be to have 6 different case structures, all with 7 cases each. The 7 cases would be "a", "b", "c", "d", "e", "f", and "0". Your input sting will need to be built up so that it will always be 6 characters long and then split up so that each character goes to one of the case structures. You would have your needed code for cases a - f. Case "0" would do nothing.

Randy Hos
kin
Applications Engineer
Nationsl Instruments
http://www.ni.com/ask
0 Kudos
Message 6 of 7
(5,598 Views)
Thank you guys for the help, but I decided to go with a boolean array, a for loop, and the array subset VI. I changed the boolean switches to their numeric equivalents, constructed an array, then set a for loop to check one element at a time, compare that value to zero, and then run it within a case structure. It works fine, and thanks again for trying. Perhaps for future versions of LabVIEW you should look into a case structure that will recognize multiple cases. That is a function I would like to see.
0 Kudos
Message 7 of 7
(5,598 Views)