From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-16-2006 11:01 PM
12-17-2006 12:29 AM
12-17-2006 01:16 AM
12-17-2006 01:33 AM - edited 12-17-2006 01:33 AM
Message Edited by tbd on 12-17-2006 01:35 AM
12-17-2006 02:10 AM
Actually, more often than not I find that you do NOT want to have a default case when dealing with enums, so that your code WILL break when you add new values. That way you can be sure that you find all places in your code where you operate on that enum and know that you handled them.
@tbd wrote:
The only thing to be careful of is that any Case-structures you wire the constant to should have Default case - that way, when the new enumeration-value appears, the code won't break. ;^)
12-17-2006 08:11 AM
I have to agree with tst re:not using defaults with enums.
I'd rather see the error at edit time than at run time.
Ben
12-17-2006 08:38 AM
Adding to my previous...
I do occationally use default cases with enums after all.
These are case structures where i want to catch programing errors at run time.
Example:
I develop libraries that can be re-used by the other engineers. Since I don't want my code behaving badly when miss-used, I will enunciate when a bad enum value has been passed.
But in both cases, I want to know as early as possible when an enums value is out of control.
Ben
12-17-2006 10:14 PM
12-18-2006 02:12 AM
Actually, the way I understand it, the demand in this case was not to have working code not break (since the actual code is only found once - in the subVI), but not having to update every instance of the enum in the calling diagrams. Your explanation that typedefs affect the diagram constants as well answers that question perfectly.
That's why I try to avoid removing items from typedef enums\clusters unless absolutely necessary and\or (I wonder what an And\Or node would look like in LV? ) I'm willing to spend the time and effort to make sure that all the places where the change would take effect have not been altered.
12-18-2006 02:19 AM
@tst wrote:
I wonder what an And\Or node would look like in LV?
Probably like this.