02-05-2010 12:54 PM
Hi,
I am trying to implement a case structure with multiple boolean cases and am having trouble with that. What I want to do here is : I have a set of 5 values, each of them being "true" or "false". For each "true" value, I have a certain set of steps to be executed. The "false" of each can be ignored. Ideally, I would like to have a case structure for the 5 "true" cases. I am not sure how to go about wiring these boolean outputs to my case structure. Also am using LabView 6.1.
Any ideas?
Thanks,
Sukanya
Solved! Go to Solution.
02-05-2010 01:06 PM
Are the value mutually exclusive? If so, you can simply build an array out of them and search for the one that's true. The index number can be used to drive your case.
If they are not mutually exclusive then you can build an array out of them and drive a for-loop using auto-indexing. In the for-loop you can have one case structure inside another. The outer case structure can be driven from the loop's iteration terminal. The inner case structure either does the steps or not, depending on the value of the current Boolean.
02-05-2010 01:09 PM
02-05-2010 01:14 PM - edited 02-05-2010 01:17 PM
Personally I like this method.
http://forums.ni.com/ni/board/message?board.id=170&message.id=453760&query.id=112270#M453760
Edit: My bad, mutual exclusivity makes this a pain.
02-05-2010 05:04 PM
sukanya wrote:
Yes, they are mutually exclusive. I did build an array with all five boolean outputs and did a search for "true". The default case always gets executed. I'm not sure where I'm going wrong!
I'm not either unless you can show us what you did.
02-09-2010 12:20 PM
This is what I'm trying to do. I did put a few checkpoints to figure out where the problem is and I found out that, the problem is at the point of comparison. It does not return a "TRUE" for any of the cases despite one of them being true. I was under the impression you could compare two strings using the "=" operator. But looks like it isn't working.
02-09-2010 12:25 PM
Funnily, I actually got it working! I tried using a string comparison function instead of a "=". It works!!
Thanks all!
02-09-2010 12:30 PM
sukanya wrote:Funnily, I actually got it working! I tried using a string comparison function instead of a "=". It works!!
Thanks all!
The reason for that is because the string you read from the serial port would have contained a carriage return and/or linefeed. Your equality is not accounting for that, which is why you never got a True out of any of them. A string comparison just checks for the existence of the text within the read string, so that would find a match.
02-09-2010 12:36 PM
02-09-2010 12:39 PM
Additional comments regarding code: