LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create a ring with many items

Hi,

 

I have a list of enum in a text base program it goes like this

 

variable 1 = 13

variable 2 = 234

..

..

..

variable 100 = 2

 

The variable names are very long.  I thought if I want to do something similar, I would have to create a ring with all these 100 values.  My questions are

 

1. Is the ring the best approach to associate a name with a value?

2. Is there a quick way to add so many items to a ring?

3. If the variable names are so long, what are the ways that I can use to save real estate while preserving clarity? 

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 5
(3,000 Views)

1. A ring is a reasonable approach. How is this being used in the program? Are these "variables" more like #define statements in C? If so you could type-def the ring, but you need to be aware that if you update the value then instances of the typedef will not update automatically, even if it's a strict type def.

 

2. Define "quick". The ring items are written using the Strings[] property or the Strings[] And Values[] property.

 

3. Kind of hard to answer this, as it depends on what the variable names are, and what they represent. 

Message 2 of 5
(2,993 Views)

1. A ring is a reasonable approach. How is this being used in the program? Are these "variables" more like #define statements in C? If so you could type-def the ring, but you need to be aware that if you update the value then instances of the typedef will not update automatically, even if it's a strict type def.

 

I didn't know that.  So I need to change the value, change the number represtation and change it back? 

 

2. Define "quick". The ring items are written using the Strings[] property or the Strings[] And Values[] property.

 

so I should write a quick vi that populate the ring? 

 

Yik
------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 5
(2,988 Views)

One thing not mentioned is that ring has to have UNIQUE values.  If two of your variables have the same value, a ring would not work.  I hate working with rings for the inability for typedefs to properly update.  I have in the past used an enum and had a VI which just got the value based on the enum.  LabVIEW doesn't allow enums to skip values, nor be negative, but it does update properly when using a typedef.

 

You can write a quick VI to get the values and strings from a file.  For enums, it is a little more complicated, as they cannot be updated while in run mode.  TO make things easier, I usually start with a ring, get the strings set and then replace it with an enum, and the string values will stick.

 

Using an enum or ring is not very space conscious, so you're pretty much stuck in that regard.  If you use the enum/VI lookup solution, you can make the icon for the VI pretty small so it doesn't take up too much space.

Message 4 of 5
(2,966 Views)

I have had a big ring get unwieldy before and so what I did was to use a constant array for the values and an enum for the indices.

 

so anywhere I wanted one of the values, I would wire the array to an Index array and an enum constant to the array index.  Then you can simplify this by putting it in a subvi, so the constant is in one place and you can create the enum constant by right clicking on the subvi's input terminal.  Don't forget to type-def the enum!

 

-Barrett
CLD
Message 5 of 5
(2,962 Views)