09-25-2024 07:23 AM
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?
Solved! Go to Solution.
09-25-2024 08:11 AM
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.
09-25-2024 08:33 AM
Do you want to iterate over the values of the Ring or the string as well?
09-25-2024 08:48 AM
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.
09-25-2024 08:49 AM
iterate over the items.
09-25-2024 08:53 AM
09-25-2024 09:08 AM
Thanks, but I need an implementation of this functionality in Constant Ring
09-25-2024 09:34 AM
@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".
09-25-2024 10:13 AM - edited 09-25-2024 10:15 AM
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.
09-25-2024 11:13 AM
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?