LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create refnum for control programmatically

Ben, I now understand the "to more specific class" issue for the property.

Part of my problem is solved.

But can you confirm that is not possibile to get a reference of a control without cicling through all vi controls?

I don't need a static refnum.

 

Example: I have controls name ctrl1, ctrl2, ctrl3, ..., ctrl10. All of them are the same type (let's say numeric)

for (int i = 1; i <=10; i++) {

    NumericControl tmp = thisVI.getControlByName("ctrl" + i.toString());

    tmp.setPropertyYouLike = ...

 }

 

 Is this possibile in some way?

0 Kudos
Message 11 of 18
(2,010 Views)

I spent about five minutes looking at your follow-up Q and I am confused.

 

You should be able to set the property (provided it is a settable property) using my clue and your previous image.

 

Is it that you do not want to walk down through the hierarchy?

 

Is "Invoke Node >>> Ctrl Val.Get" where you pass a ref to for the VI holding the control and you pass the "Control Name" what you are looking for?

 

Maybe some LV pseudo code with a place holder in the diagram that we can help on.

 

I hope that helps (somehow),

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 18
(1,997 Views)

How about a different approach?  If you make a cluster of a Multiplier and a Value control, then when the Multiplier changes, change the value of the Value in the same cluster.  The CtlRef in the Event case should point to the particular "Cluster x" which changed.  Bundle by Name will give you access to the Value component.

 

Lynn 

0 Kudos
Message 13 of 18
(1,987 Views)

And I spent 5 minutes to draw in Labview the code I wrote in C# in 5 second 🙂

Let me see the light!

I speak in general for a general control , I don't need only the "get/set value" property 

thanks 

 

Clipboard01.png

Message Edited by Slyfer on 05-28-2009 02:51 PM
0 Kudos
Message 14 of 18
(1,984 Views)

Slyfer wrote:

And I spent 5 minutes to draw in Labview the code I wrote in C# in 5 second 🙂

Let me see the light!

I speak in general for a general control , I don't need only the "get/set value" property 

thanks 

 

Clipboard01.png

Message Edited by Slyfer on 05-28-2009 02:51 PM

 

I am a physics/EE, and material scientist type by education and never took any software courses so you have me curious what is "offensive" about that last approach?

 

Could you enlighten me?

 

Trying to learn something,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 15 of 18
(1,979 Views)

You might want to look into OpenG VIs, I think you could use the "Get Control Value (variant)". It lets you get the value of a control by giving it the control name. I know you were also interested in other properties for the control, but maybe exploring how this VI was made can point you in that direction.

 

http://wiki.openg.org/Get_Control_Value_(Variant) 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 16 of 18
(1,973 Views)

?? 

 

"offense to software engineering" means that is *absurd* to iterate through *all* the controls in a panel when I know which subset of control I need to modify.

In my example I need to modify only the controls whose name is "ctrl"+x  (+ means "string concatenation"), where x belongs to the set {1,2,3,4,..,10}.

An "engineered procedure" is not supposed to waste cycles, don't you think so?

 

just my 2 cents, of course, never meant to offend anyone in here! 🙂

 

@fabiola, no I don't need "get value" property, I wrote this 3 times 🙂

 

Suppose you want to initialize some properties of a group of controls with similar names. It's not possibile (in general) to group them in a cluster.

 

In javascript DOM: it is possibile to  get a element of a DOM directly without walking through the tree. GetElementByID. And ID is unique.

So in this case, I can do a for loop like the one I wrote before.

Another example is XPath: again, it is possible to reach directly a node with an expression.

 

The original question of this topic has not an optimal solution, according to me, because the guy asked a programmatic way of creating a reference to a control, and the answer was something like "get all references and loop through all of them"

0 Kudos
Message 17 of 18
(1,964 Views)

Slyfer wrote:

?? 

 

"offense to software engineering" means that is *absurd* to iterate through *all* the controls in a panel when I know which subset of control I need to modify.

In my example I need to modify only the controls whose name is "ctrl"+x  (+ means "string concatenation"), where x belongs to the set {1,2,3,4,..,10}.

An "engineered procedure" is not supposed to waste cycles, don't you think so?

 

just my 2 cents, of course, never meant to offend anyone in here! 🙂

 

@fabiola, no I don't need "get value" property, I wrote this 3 times 🙂

 

Suppose you want to initialize some properties of a group of controls with similar names. It's not possibile (in general) to group them in a cluster.

 

In javascript DOM: it is possibile to  get a element of a DOM directly without walking through the tree. GetElementByID. And ID is unique.

So in this case, I can do a for loop like the one I wrote before.

Another example is XPath: again, it is possible to reach directly a node with an expression.

 

The original question of this topic has not an optimal solution, according to me, because the guy asked a programmatic way of creating a reference to a control, and the answer was something like "get all references and loop through all of them"


 

Thanks for the clarification!

 

I am going to file that away as a matter of taste since using that method of accessing Fp opbjects would drive me nuts*. One of my rookies wrote some re-use that runs through all of the object once every time a VI is re-compiled and then caches all of the references in a look-up table (Action Engine) that he can index using an enum with the names as you have described. So it can be done, but is not availabe "out of the box".

 

Ben

 

 

* nuts: Years ago I stared at some code I was writting in DCL (Digital Comand language) and simply could not figure out what was wrong with my syntax. evenentually I figured out the word "length" had a "g" in it. when I first saw LV and realized there was NO syntax involved, I thought I had died and gone to heaven! So for the dyslexics of the world, LV is a gift from God.

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 18 of 18
(1,959 Views)