LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load the String List of an Enum programmatically


@crossrulz wrote:

@MrJackHamilton wrote:

If you wired up the error cluster...you'd see LabVIEW does not allow this. What is odd is that LabVIEW should.


No, it should not.  You are trying to update an enum while it is in a run state.  That definitely should not be allowed.  From another VI, you can get a reference to this VI and update the enum.  That is because then the VI with the enum will be in an edit state.


It's not just "it should not", but it must not.  The enum strings are part of the data type, and data types cannot change at runtime.  If you wire an enum to a case selector, and have a case for each possible enum string, that code would break if the enum strings changed.  Asking to be able to change enum strings at runtime is asking to be able to have code render itself uncompilable.

0 Kudos
Message 11 of 13
(299 Views)

Hi @francsicohdz,

 


@francsicohdz wrote:

Hello ,

 

Here an example of programmatically fill the elements of enum

programmatically.  for enum controls the data cannot be fille during exection , the this vi is open the cotrol from another VI and adding the data 🙂

francsicohdz_0-1723119475260.png

 


Type-casting a refnum like that can be dangerous (if not done correctly), it is safer to use "To More Specific" instead.

 

Also, the Panel refnum does not need to be closed, it is a no-op. See this post from Darren.

 

Finally, if you use VI scripting for e.g. creating automatically an enum type definition, you will need to call VI method "Save.Instrument" at the end to apply changes and make them persistent.

 

Regards,

Raphaël.

Message 12 of 13
(284 Views)

I think you would also want to apply changes and save the .ctl.

et.png

Message 13 of 13
(265 Views)