LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

type definitions and enums

Maybe this is not a correct use for type definitions, and to be honest I just started using them in my vi's.  But I was wondering, can I use a type defined combo box to auto update the combo box control from one vi to the next? To demonstrate I attached some sample files.  The first vi is named enum1.vi

It's input is a combo box control containing two items "Test 1" and Test 2"  and an output that is an integer showing which test is chosen.  I have saved this combo box as a strict type definition in cntrl 1.ctl 

 

The 2nd vi is enum2.vi and has nothing but enum1.vi and has it's input and output wired accordingly to a control and indicator.  How do I make enum2.vi update it's combo box control automatically when I change enum1.vi?

 

Regards,

 

-SS

 

Edited files from 8.6 to 8.0 so more people can view.

 

Message Edited by ShotSimon on 08-29-2008 10:37 AM


Download All
0 Kudos
Message 1 of 20
(3,624 Views)

That is the reason why Type Defs. are so powerful.

 

You want to go into your Enum2.vi whose control is currently just an ordinary one.  Select the control, right click, and select replace.  Pick the Control1.ctl.  Save the file.  Now whenever you open up the Type Def control and edit it, all instance where the control is used, (which will now be Enum1.vi and enum2.vi) will be updated.

Message 2 of 20
(3,612 Views)
Thanks RF.  I was missing the whole idea that you have to use the custom control in all the vi's.  -SS


0 Kudos
Message 3 of 20
(3,592 Views)

RF,

 

Is there a bug still regarding the use of enums as constants in LabVIEW 8.6?  I seem to remember reading this and came across this problem when updating my code.  In other words you are required to change every constant to a control and back to a constant for the enum parameters to update accordingly.

 

Regards,

 

-SS



0 Kudos
Message 4 of 20
(3,542 Views)

SS,

 

To the best of my knowledge there isn't a bug in the enums. What issue are you refering too?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 20
(3,539 Views)

This may be a misunderstanding on my part.  When I take an enum control that has been type defined an change it to a constant should I expect the enum to change when I update the *.ctl file? Or does changing it to a constant break it's ties to the *.ctl file? -SS



0 Kudos
Message 6 of 20
(3,532 Views)

No, the cosntat enum should retain its value UNLESS you delete the choice from the enum. In that case it should break and remind you that the constant has to be set to a valid choice.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 20
(3,528 Views)

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
Message 8 of 20
(3,527 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 20
(3,523 Views)

I t remember a special condition that I mentioned in my Type def Nugget

 

If the enum is in a cluster and the cluster is edited to either add or remove fields, then default value of the enum will be used in the cluster constant on the diagram. This is why I encourge developers not to rely on the value in a cluster constant but rather explicitly "Bundle by Name" the proper enum value.

 

Like I said, I illustrated this in my Nugget.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 20
(3,519 Views)