03-16-2009 10:31 AM - edited 03-16-2009 10:32 AM

03-16-2009 10:46 AM
03-16-2009 11:28 AM
03-16-2009 11:35 AM - edited 03-16-2009 11:36 AM
BME genuis wrote:
How many cases do I have to put into the case structure?
As many as you had in your original code. 9 I believe you said you had. You don't need to have any code in the cases. You just need the cases.
So you are thinking when it is a non-case value that it will execute the state at the end of the state machine?
I don't honestly remember 100%. It's been a long time since I've used LabVIEW 5.
You could, of course, deal with the situation differently if you want something a bit more robust. You could, for instance, have an outer case structure that handles if the value is above 10.
03-16-2009 12:28 PM
03-16-2009 12:37 PM
03-16-2009 01:09 PM
03-17-2009 08:02 AM
03-17-2009 12:32 PM
If you use an enum, you define all of the values contained in that enum...ergo, you can (and should) specify a case for each value of your enum. That way you can guarantee that you won't be feeding values to your case structure that aren't handled by the structure. If you aren't going to code up a case for each value of your enum, then you should use a default case.
If you aren't going to use an enum as described above, then you should certainly specify a default case.
The key here is that, by having a default case, you know exactly what your code will do in all circumstances, even unexpected ones. That's very important, particularly if you're planning on ever using the code for anything. Random, unexpected behavior is very annoying to the user (and to the programmer).
I'm curious about the discrepancy that exists in your posts -- supposedly the case structures inside your main VI don't require a default case, but when you try to code up the very simple examples posted here to test case structure behavior in 5.1.1, LabVIEW tells you that a default case is required. I presume that you are using the same copy of LabVIEW in both instances? If so, then there is a detail here that's missing. What is it?
03-17-2009 01:13 PM