06-05-2014 07:54 AM
Hi all
I want to compare the name of a control with a variable inside a loop. Is there any function for it in Labview? Please let me know if it is.
Thanks in advance
Solved! Go to Solution.
06-05-2014 08:47 AM
Execute the right-click menu (on the Control / Indicator) > Create > Property node > Label > Text. Compare the two strings. Is the loop anyhow important or interesting for the problem? If yes, then post your VI, please.
06-06-2014 01:03 AM
Actually my main objective is this ........
There are two arrays - one has variable names and the other has their corresponding values. I want to map these values into different controls based on the control names which are the same as variable names in the array i mentioned before. I was thinking of using loop in some way but am not getting anywhere with that... Is there any way to do that???
06-06-2014 01:27 AM
You can use the VI pane reference and use the Controls[] proerty (array of reference to the controls available in the particular vi) in a for loop and read the label text and match it with your array and update the value. Is that what you want to do?
06-06-2014 05:50 AM
Thanks for the solution .... I am able to get the control references and match it with my input array.... But how to update the value??? I can just use case structure if number of controls is constant every time.But its not possible as the number of controls will keep changing depending on my requirement. So I want a solution to generalise this so that an external user can automatically pass the input values into any vi. Please suggest me something about this.
06-06-2014 06:15 AM
I am reading your posts, but I do not understand the situation. I am simply lost in the terms and naming. Could you post your VI, please?
06-06-2014 06:46 AM
You should only need a case structure case for each control type, ie one for Numeric, one for String, one for Path etc.
When you compare the control's label text to the string you have, if it matches then you need to them downcast the control's reference to something more specific to that control, which will enable you to use the Value property node with true datatypes.
If you don't know the control datatype then you have to use a trial and error method of attempting to determine it by casting the reference to something more specific and checking the error out. If no error then you've successfully downcast it, and can then use the appropriate case to set the value.
If you've got dozens of control datatypes that you wish to support then this can get tiresome.
06-06-2014 07:18 AM
Please show us what you have done so far, then it will be easy to come to a conclusion.
06-06-2014 07:19 AM
Hi ghighuphu,
I am attaching an example VI for our objective.
In the VI we are giving 5 'Variable names', 5 'Variable values' as inputs. And also we are giving an array consisting of the 3 required 'control names'(These 3 controls are on the right side of block diagram). First we are getting only the 3 required values from available 5 values. Now we want to pass these 3 values to their corresponding controls named a,b and c on the right side of the block diagram. So that they can be added and give the output.
I want a generalised solution so that it works for varying number of controls.
06-06-2014 07:31 AM
P@Anand wrote:
You can use the VI pane reference and use the Controls[] proerty (array of reference to the controls available in the particular vi) in a for loop and read the label text and match it with your array and update the value. Is that what you want to do?
I think that's the solution.
To update a,b,c use the references and a value property node.
Best regards
Florian