LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

type definitions and enums


Ben wrote:

JeffOverton wrote:

I don't know about 8.6, but in 8 through 8.5 the constant will update when you change the typedef.

 

edit - Specifically if you add options to the enum, the constant will update to allow those new options to be selectable.

Message Edited by JeffOverton on 09-04-2008 10:53 AM

... but after the update the value it was set too will be retained as long as that value is still present. When I say "value" I'm refering to the string that was selected. Even if the enum is re-ordered such that the numeric value associated with the string is different, it should still have the same stirng selected.

 

Agreed?

 

Ben


 

Oh, I agree with that, yes.  The specific value of that specific constant instance of the type def will remain the same unless it's deleted from the type def.  I was speaking more in terms of enumerating states for a state machine, and if you add a state to the typedef, you can just right click the case structure and "add case for all values" because the constant will autoupdate as well.
Message 11 of 20
(1,481 Views)
In enum1.vi I changed the enumerated type defined control to a constant and saved.  In Control 1.ctl, I added an item and saved and then select apply changes.  The constant in enum1.vi doesn't update? -SS 


Download All
0 Kudos
Message 12 of 20
(1,459 Views)

I see what you mean. But there is one complication in your example.  You do not have an Enum.  You have a ring control.

 

I'm not sure if the behavior being shown is expected or not, but I know that there are some differences between enums and ring controls.  In enums, the name of a value is an integral part of the control.  In rings, the value is the key item, the name used in the display is more of a "decoration" and is not a critical part of the definition.

 

That is why if a control's names needed to be changed during runtime, it is required to use a ring rather than an enum.

Message 13 of 20
(1,450 Views)

Ravens Fan wrote:

In rings, the value is the key item, the name used in the display is more of a "decoration" and is not a critical part of the definition.

 

That is why if a control's names needed to be changed during runtime, it is required to use a ring rather than an enum.


 

I believe that is expected behavior, because of the following:  Wire a ring to a case structure and wire an enum to a case structure, and the selectors will be completely different.  Additionally, the terminal of a ring control  even says U16, while an enum is just the left and right arrows.

Message 14 of 20
(1,443 Views)
Yes sorry I was using a ring instead of enum.  But when I change everything to enum my constant doesn't update as I was expecting.  I saw this happen the first time but not after that.  -SS


0 Kudos
Message 15 of 20
(1,439 Views)
The first time, as in you changed the typedef, opened your VI (and the constant was changed), then changed your typedef again and the constant didn't change?  Is "Auto-Update from Type Def." checked?  Is your typedef strict?
Message 16 of 20
(1,432 Views)

Try this.

 

Go to your Ring constant.  Right click change to control.  Right click change to constant.

 

I don't know why, but that seemed to update the control to the saved type def. which persisted when it changed back to a constant.

 

It isn't automatic and in the background, but it did do the update in a few mouse clicks.

Message 17 of 20
(1,424 Views)

I replaced the ring constant with an enum constant.  The values from the ring did not automatically transfer over, so I had to edit the enum constant to add all the items.  I then made it a strict type def and saved it.

 

After that, I opened the control.vi and edited and deleted items, then saved it.  I didn't see any problems with the enum constant being updated automatically when I edited the strict type def control.

 

 

Message 18 of 20
(1,419 Views)

JeffOverton, Yes "Auto-Update from Type Def." is checked and typedef is strict.

 

Ravens Fan, Yes your work around will work with ring controls but I was trying to avoid this.

 

The problem went away since I was accidentally not applying changes from the ctl file, this is importantSmiley Wink

 

Thanks guys for your help, I'm still learning the in's and out's of this useful feature.  -SS

Message Edited by ShotSimon on 09-04-2008 03:28 PM


0 Kudos
Message 19 of 20
(1,393 Views)

ShotSimon wrote:

The problem went away since I was accidentally not applying changes from the ctl file, this is importantSmiley Wink


haha, that'll do itSmiley Wink

 

also, if you save the changes (but don't apply them) and then close the .ctl it will automatically apply the changes

0 Kudos
Message 20 of 20
(1,370 Views)