Jump to content
A Scottish moose

Adding values to Enum resets all instances to default

Recommended Posts

Hey everyone,

I'm working on a midsize (Actor framework) project that has a main command message that gets used by all of my nested actors.  This command messages payload is a typedef enum that defines what job gets done.  As I've been developing the project I've been adding values to the enum and handling the resulting job in the 'send command.vi' message....  This works well because all of my nested actor messages that don't have a payload just send a constant enum to the controller to request a job... so I'm adding a new function to the said enum and after editing the typedef LabVIEW resets ALL constant instances of this typedef to default across my entire project. Every instance in memory of this enum gets set back to the zero value.  I have everything backed up in SVN so this isn't a big deal from a time standpoint for me but I don't think this is intended behavior.  Has anyone else seen this?  

 

TL/DR - I have a typedef enumeration and after adding a value to the end of the enum it resets ALL constant instances of this enum to value 0... ideas?

 

Thanks,

 

Tim

Edited by A Scottish moose

Share this post


Link to post
Share on other sites

That's just the way it is, move along (and remember to always check at least some of your enum instances after editing). In LV2014 they added this to help: http://zone.ni.com/reference/en-XX/help/371361L-01/lvhowto/manual_update_typedef/

My collegue claims that editing enum elements in Enum Properties window is better than editing in-place using ctrl+click on the control (i.e. value resetting doesn't happen so often) - but I'm not sure about that.

Share this post


Link to post
Share on other sites

If you are just adding to the end of the enum, I don't think the enum constants are supposed to reset.  I have ran into issues when changing names and/or adding in the middle, but the Update Typedef tool is used to fix those.  Now I have to go play around with this...

Share this post


Link to post
Share on other sites

I don't seem to have this problem, but I always use "Edit Items..." and I'm careful to only make one change at once (rename one thing; or move one thing; don't ever rename and move).

Share this post


Link to post
Share on other sites
2 hours ago, crossrulz said:

If you are just adding to the end of the enum, I don't think the enum constants are supposed to reset.  I have ran into issues when changing names and/or adding in the middle, but the Update Typedef tool is used to fix those.  Now I have to go play around with this...

Exactly!  This was my thought too, and the exact reason I add at the end of an enum if at all possible.  Going to work on it some more today and see if I can figure out why.

Share this post


Link to post
Share on other sites

I've always added new items to the end.  It does make organization look a little out of order but functionally I've never had a problem.  The 2014 approval dialog does come up once in a while when I'm removing items, and seems to work well.  Maybe you are removing, moving, and adding too many items at once and the attempt at preserving values fails.  If you do one edit at a time I wonder if you'll see the problem.

Share this post


Link to post
Share on other sites

I hate the silent mutation. I wrote this idea a while back: https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Deleting-an-enum-element-from-a-type-def-should-cause-a-broken/idi-p/1763158

I'm curious what actions specifically default the value. What version are you using? 2014 helped but I know there's still some mutation going on with the case structures now.

Share this post


Link to post
Share on other sites

 

Do you use strict typedefs by any chance?

I've had a similar issue a couple of years ago (using LV2011). It turned out that the reset was caused by using strict typedefs instead of regular ones. Changing from strict to regular typedefs solved the issue (after fixing the project one last time of course).

Share this post


Link to post
Share on other sites

Using 2016.

 

 Checked the strict Type Def idea, nope, using regular type def. Good idea though!

 

 I've tried to reproduce it a bit today but haven't had much luck.  Yay for non-repeatable failures!

Edited by A Scottish moose

Share this post


Link to post
Share on other sites

Have you tried clearing the compiled object cache? Here is a post that sounds exactly like the problem you've got:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.