06-06-2016 02:25 PM
Running into a weird problem with Enums. I'm trying to dynamically populate an enum to allow for some dynamic dispatching during a user input phase. I'm almost done, and this happens:
The front panel on the right is the "Setup Enum" vi. On the left is the main VI, with a strictly typed enum control reference going into that VI. I've attached the vi hierarchy; open "Choose Curve.vi" to troubleshoot.
Solved! Go to Solution.
06-06-2016 02:36 PM - edited 06-06-2016 02:41 PM
Solved this issue by changing to Ring datatype. One more issue, when I modify the label/increment-decrement property on this control manually, the code for changing the label via a property node doesn't work unless I run the subVI individually. I have the subvi ("All Curves Base Setup.vi") open (edit: same behavior no matter if the VI is open or closed). Why is this?
06-06-2016 03:04 PM
Also solved. The problem was that the Label property is not modifiable at runtime. I used the Caption property instead, which has much the same function.
06-07-2016 12:56 AM - edited 06-07-2016 12:57 AM
I didn't check your actual code, but to be clear, making the enum reference strict causes it to look at the values of the enum too, so two strict enum references which point to different enums don't match, as you see. For your wiring to work, the enum reference control on the subVI would have to be non-strict or they would have to match.
Even if they did match, that wouldn't help you, because like the label, the strings of an enum can't be set while the VI they're in is run mode, because they are part of the data type. As you saw, a ring is the appropriate option for this use case.
06-07-2016 06:17 AM
06-07-2016 07:35 AM
@ijustlovemath wrote:
Can control references be not strict?
Absolutely. If you right click a control and select Create>>Reference, then that will output a strict reference, but the control shown in your subVI certainly doesn't need to be strict. You can right click it play with it, you can drag other types into it to change the class, etc.
Even with the strict references, you could wire two incompatible strict references into a Build Array and it will simply change the reference type of the array to the common class (and show you the coercion).