LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A for-loop to iterate over ring

Solved!
Go to solution

How can I create a for-loop in LabVIEW to iterate over a Ring control, similar to using the "Enum to Array of Enums.vi" function for an Enum?

 

maxnoder1995_0-1727266981507.png

 

0 Kudos
Message 1 of 11
(455 Views)

You can't.  (Unless your ring is strictly typedef'd.  See below.)

In an enum, the strings and values are part of the data type; and therefore the values and strings are in the wire type and are accessible to anything that the wire connects to.

However with a ring, the strings and values exist only in the controls, indicators, and constants, they are not in the wires; the data type of the wire is just an integer.  (It is because the strings are not part of the data type that you can change them at run time.)

 

If your ring is strictly typedef'd, you could use Data Type Parsing to find the path to the typedef, then extract the strings and values from there.

0 Kudos
Message 2 of 11
(426 Views)

Do you want to iterate over the values of the Ring or the string as well?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 3 of 11
(415 Views)

If your ring is strictly typedef'd, you could use Data Type Parsing to find the path to the typedef, then extract the strings and values from there.


Can you show me an example? I don't see how this can be done.

0 Kudos
Message 4 of 11
(407 Views)

iterate over the items.

0 Kudos
Message 5 of 11
(402 Views)

Do you just want to loop over the values in the ring?

jcarmody_0-1727272388826.png

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 11
(397 Views)

Thanks, but I need an implementation of this functionality in Constant Ring

0 Kudos
Message 7 of 11
(386 Views)
Solution
Accepted by topic author maxnoder1995

@maxnoder1995 wrote:

If your ring is strictly typedef'd, you could use Data Type Parsing to find the path to the typedef, then extract the strings and values from there.


Can you show me an example? I don't see how this can be done.


Here.

One very important caveat: If you make changes to a strict typedef of a ring, then apply those changes, by default, the changes will only be applied to controls and indicators, not to constants.  However there is an undocumented property of ring constants called "Act as Strict Typdef Constant" which, when set, will have applied changes propagate to that constant.  I have set that property to TRUE in the constant in "My Ring Item Iterator.vi".

Download All
Message 8 of 11
(379 Views)

Rings can have non-sequential values and I assume you want to iterate over the values, not item names.

 

Just get the "string and values" property an iterate over the elements of the array. Inside the loop, unbundle what you need.

 

altenbach_1-1727277194636.png

 

 

 

Message 9 of 11
(361 Views)

PERFECT! Thank you very much! By the way question, Why not close the reference of the VI right after the property node that brings the reference of the Panel? Why close the references at the end of the program?

0 Kudos
Message 10 of 11
(345 Views)