LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to dynamically change enum file on LabVIEW

Solved!
Go to solution

So far we are able to change ring value dynamically with LabVIEW but not for enum with .ctl files. Is there any effective method to dynamically edit the contain of the enum using LabVIEW?

0 Kudos
Message 1 of 16
(834 Views)

Hi skykong,

 


@skykong wrote:

So far we are able to change ring value dynamically with LabVIEW 


Yes.

 


@skykong wrote:

Is there any effective method to dynamically edit the contain of the enum using LabVIEW?


Nope.

Enums are defined at edit time (as they define the datatype).

Changing them requires to recompile your executable - which isn't possible at runtime…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(829 Views)
Solution
Accepted by topic author skykong

You can, but the Enum must not be reserved for execution.

This example works as long as no running vi uses the ctl:

editenum.png

Of course, the file MyEnum.ctl must exist already.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 16
(812 Views)

Great! Can you provide the vi for references? Thanks.

0 Kudos
Message 4 of 16
(803 Views)

@skykong  ha scritto:

Great! Can you provide the vi for references? Thanks.


It's a snippet. Save it as a picture (.png) and then drag it into a Block Diagram.

Of course, you need LV>=2021

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 16
(797 Views)

@pincpanter wrote:

You can, but the Enum must not be reserved for execution.

This example works as long as no running vi uses the ctl:

editenum.png

Of course, the file MyEnum.ctl must exist already.

 


Maybe we should take a step back and ask why updating a ring is not sufficient?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 16
(780 Views)

This method won’t work because this only workable if execution is stop. Is there any method that work with executable is continue running?


 

0 Kudos
Message 7 of 16
(610 Views)

@skykong wrote:

This method won’t work because this only workable if execution is stop.


This is what others were meaning when they said:

 

@: "Enums are defined at edit time (as they define the datatype).

Changing them requires to recompile your executable - which isn't possible at runtime…"

 

and

 

@"the Enum must not be reserved for execution.

This example works as long as no running vi uses the ctl"

 

 


@skykong wrote:

Is there any method that work with executable is continue running?


Enums by definition are not editable at runtime. If you want a drop-down list with items settable at runtime, you have to use either a Ring (numeric data type) or a Combo Box (string data type).

 

Regards,

Raphaël.

Message 8 of 16
(591 Views)
Solution
Accepted by topic author skykong

Actually, I encountered this issue about 10 years ago during my early experience with LabVIEW coding. While there are always workarounds, I'm still curious to see if a proper resolution exists now. but it still seems like a dead end. The reason I prefer using an Enum over a Ring or Combo Box is that a Ring only passes numeric values to the case structure, and a Combo Box requires manually renaming the case labels before use. In contrast, an Enum automatically updates the case structure names based on its items. You can even update the cases and extract state names when needed. Just sharing. Cheers!

out1.png 

out2.png

out3.png

0 Kudos
Message 9 of 16
(458 Views)

All of your advantages only affect edit-time behavior.  Why do you need it to work during run-time?  If you have some run-time activity that suggests changes to the enum for later edit-time activity, try recording all needed changes until shutdown, then unload the control and use pincpanter's approach before finally closing everything.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 16
(447 Views)