From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Creating an Enum Using VI Scripting

Code and Documents

Attachment

Overview
This example VI demonstrates the method to programmatically create an Enum using VI Scripting.

Description

The VI first creates a new VI at the path selected by the user in the File Dialog. It then opens a reference to the Block Diagram of this new VI and feeds this into a New VI Object function that creates an Enum Constant. This constant is then populated with the items from the String Array Control.

Once it has done this, and closed off the references, it saves the changes to the VI and then opens it for you to view.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Open the VI " VI Scripting - Creating an Enum Constant 2012 NIVerified.vi"
  2. Enter all the Items you want to be in your Enum into the String Array Control
  3. Run the VI.

 

Additional Information or References
VI Snippet

Block Diagram.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

James W
Controls Systems Engineer
STFC

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
EWiebe
Active Participant
Active Participant
on

Thank you very much!

-------------------------------------------------------------------
Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
1ERC
Member
Member
on

James_W,

WoW! - I developed an idea that would allow an ENUM to be used for accessing the correct constant in a meaningful way, thought "this would be great for a script, if I knew how" and actually found the answer on NI's site - FANTASTIC!!!

HOWEVER! - The criminal/evil Wallmart Money-Grubbing mentality has struck again:

  o  Despite insane SW prices that prevent me from owning up-to-date LV at home, NI refuses to provide reliable support

  o  My employer will not provide up-to-date LV at work

  o  You did not provide an example I can use with LV 2010

ThanX?

1ERC

JTG_Wilson
Member
Member
on

Hi 1ERC,

I'm sorry that you've had difficulty getting support from NI engineers but, despite what my profile on here might say, I'm no longer an NI employee so can't really do anything to help you there. I have, however, added a version of the code saved for LV2010 so hopefully you'll now be able to try out the example.

Regards,

James

James W
Controls Systems Engineer
STFC
1ERC
Member
Member
on

ThanX James,

After I wrote the nastyGram from exasperation, I was able to re-create the Script from the fuzzy picture and IT WORKED! I will compare it to your kind 2010 ENUM Script.

ThanX again and best regards,

1ERC

MatiasMan
Member
Member
on

This help me a lot to create a beautiful polymorphic vi.Smiley Happy

Thank you very much!