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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get a ctrl with certain name

Solved!
Go to solution

Hello everyone,

I have 20 arrays named z=1, z=2,... z=20; Now a for roop was created to assign numbers to each array, but how could I get the array with name z=i?

 

0 Kudos
Message 1 of 7
(3,119 Views)

hi,

 

your question is not clear, From my poor understanding, I guess you have array of 20 elements and you want particuler array element for that you need to use the 'Index Arrray' function fron Fuction pallette->Array

-
Amit
CLAD
0 Kudos
Message 2 of 7
(3,108 Views)

Thanks very much for your concern... but it's not the case.

For example, I have 20 string indicators, named as z1, z2, ... z3.

I want to input something to one of the string indicators, zi, how could I do that?

 

for i=1:1:20

     zi=a

end

    

0 Kudos
Message 3 of 7
(3,099 Views)
Solution
Accepted by topic author asdfasgghgfasdhgasgsadaas

My immediate thought would be to create an array of references to the indicators, you can then index that array to get the z<i> indicator and then write to the value property node to set its value.

 

If it does need to be truly dynamic based on name, you can also...

- use the 'Ctrl Val.Set' method of a VI to set a value by name

- find all indicators on the front panel and then look up the reference by name


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 7
(3,073 Views)
Solution
Accepted by topic author asdfasgghgfasdhgasgsadaas

This'll find the indicator by its name and will work as long as you don't have anything else with the same name.

 

Example_VI.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

0 Kudos
Message 5 of 7
(3,064 Views)

Thank you very much

it gets

0 Kudos
Message 6 of 7
(3,041 Views)

Also the Find Object By Label which is in your vi.lib, exposed with the Hidden Gems, can do this for you to.  Provide the name of the control, and it will return a reference to that control that you can then set the value of.  Depending on your design one might work better than the other.

Message 7 of 7
(2,946 Views)