LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to update type-def programmatically

My application is consisted of various sub-VIs.
To select some instrument setup, I used an common enum control in main VI.
In this case, I used the type-def enum control (control.ctl) to update in all sub-VIs.
 
In some situation, an user can define the instrument setup file by editting setup.ini.
Therefore, the enum control should be updated in executing.
 
My problem is the enum control property node can't be used in updating the type-def enum control.
(The type-def and strict type-def are not allowed to write via the property node.)
 
If so, how to update the type-def enum control programmatically?
 
0 Kudos
Message 1 of 12
(5,266 Views)
You can't update the "Strings[]" property of an enumerated type while the VI is running. You CAN do this with the Text Ring and Menu Ring controls however.

0 Kudos
Message 2 of 12
(5,258 Views)

Hi there

the "Strings[]" property of Text Rings and Menu Rings is NOT part of their strict typedefs data, so even if you use a Ring you aren't able to update the "Strings[]" of all the Ring's instances.

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 12
(5,249 Views)

Hi labmaster,

      I don't think this is going to help you - it sounds like you need the enum to be on a running diagram during the update and, like Bill said, you can't update the enum "strings" property while it's on a running VI,

...  but you can write to its "strings" property programmatically - via reference if you:

1) Open a reference to a non-runnng VI with the target-enum on the FP

2) get the Front Panel "Controls" [array] property,

3) Find the right reference (look at each control-reference if there's more than one)

4) Write to the strings property (programmatically)

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 4 of 12
(5,244 Views)
whops, my post valid for "typedefs", not "strict typedefs"....
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 5 of 12
(5,241 Views)
It can be done, but I advise you not to....

Here's how:
-Close all VIs owning the Typedef
-Create a new Typedef with the following code
-Save it under the same name
-Open up your VIs and the Typedef should be updated

The problem lies in the fact that your case structures will react in strange ways, most likely your code is broken because there might be less items in the new enum and there would be cases for non-existing items which LabVIEW can't handle

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 6 of 12
(5,229 Views)

I love these "YES YOU CAN!" replies to traditionally "No you can't" questions.

Ton wrote

"

The problem lies in the fact that your case structures will react in strange ways, most likely your code is broken because there might be less items in the new enum and there would be cases for non-existing items which LabVIEW can't handle.

"

If all of the case structures have a default case that enunciates an un-handled condition, you can survive these dynamic changes.

Now if we could only do this in an executable... Smiley Wink

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 12
(5,214 Views)

Hi Ben,

      To be fair to BILL @ NGC who responded "you can't update the Strings[] property of an enumerated type while the VI is running".  Isn't this accurate?  I don't think this has been refuted or disproven - just a couple of work-arounds (including mine) that won't do what the original poster requested.

My sense, reading Ton's post, was that Ton responded mainly to the subject-line, not the content of the post: "the enum control should be updated in executing" (translation: "the enum control should be updated while executing"). 

Your reply seems to be denigrating a concise and accurate reply(?)

Regards.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 8 of 12
(5,182 Views)

Sorry it cam across that way. Smiley Sad

My intent was to encourage thinking outside the box and finding new was to "break the rules". Smiley Wink

That is how scripting was uncovered etc.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 12
(5,175 Views)
My colleague Ben ( Smiley Wink ) brings up a good point concerning case structures and enums, and in the spirit of his "thinking outside the box" comment, consider that there can be situations where you want the code to break if an enumeration changes. Take for example a VI that is parsing an input based on the value of an enumerated input. In those situations I don't want a default case. The broken arrows will help me find the places where I need to add code to deal with new enumerations.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 10 of 12
(5,169 Views)