Example Code

Creating a Case Structure and Populating the Cases using VI Scripting

代码和文档

添加附件

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

Description

The need may arise within a program to update the values of a control such as an Enum or Ring Control during Run Time. In this case there are a couple of things to be aware of.

Firstly, this is possible by VI Scripting as can be seen here and here. Secondly, the method used to update the Text Ring as in this example can not be used for Enumerated Controls - this alone can be done by VI Scripting. In the following VI, a simple Property Node can be created from Right Clicking on the Text Ring Control in question. The property to be selected in this case is Strings[].

In this case, it is put in a little more context by the String Search functions used to populate it - this could be any string from any source.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Open the VI " Ring Changer 2012 NIVerified.vi"
  2. Fill the Original String Values with whatever Values.
  3. Run the VI.

 

Additional Information or References
VI SnippetBlock Diagram.png

 

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

James W
Controls Systems Engineer
STFC

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

评论
Herlag
Member
Member
修改时间

Hi James,

Nice and useful job.

HL

ChuckS
Member
Member
修改时间

I agree nice ... saved me some work

Frank_Pontes
Member
Member
修改时间

HI James, would you be so kind to save the file so it is compatible with Labview 2010?

Varunesh
Member
Member
修改时间

great

eldiego
Member
Member
修改时间

Great job, James!

Is it possible to do the opposite? Create and populate an array of strings where each string is the case label.

CLA
JTG_Wilson
Member
Member
修改时间

Hi Eldiego,

You can probably do what you are asking by using the FrameNames property node. If you search in the example finder for 'scripting' and load the VI Scripting with Structures - Case Structure.vi it will show you various properites for case strucutres that you can get and set using VI scripting.

I hope this helps.

James W
Controls Systems Engineer
STFC
tmccrack
Member
Member
修改时间

Nice, just used this for generating cases for a queued state machine. Thanks