cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Programatically obtain strictly typed control reference within TabControl within SubVI

Solved!
Go to solution
Highlighted

Programatically obtain strictly typed control reference within TabControl within SubVI

Hi, I am attempting to access a control refnum that is within a Tab Control within a separately opened VI. I have figured out how to do this but only if I use a "to more specific class" object with a strictly typed reference created within my "control VI".  The problem is that some of the other SubVIs I will be controlling will have different numbers of tabs and so I cannot just use one universal type reference. If I could just get the strict type of a TabControl from it's reference that would solve my problem. Is there a way to do this? 

 

Sorry, if my language is not correct as I'm still learning about this stuff. I've attached the SubVi that I'm trying to make which might help to understand. 

 

 

0 Kudos
Message 1 of 9
(152 Views)
Solution
Accepted by topic author Ben
09-26-2017 06:45 AM

Re: Programatically obtain strictly typed control reference within TabControl within SubVI

You may want to take a look at an old Nugget I wrote on exploiting Control references. It starts simple and goes all the way to save restore data to disk.

 

I do not think your reference have to strict they just have to be of the correct type.

 

Also loo k at the Variant palette because they have added a lot of things that make that work easier (where were they back in LV 8? So NOW they add them.)

 

Ben 

0 Kudos
Message 2 of 9
(139 Views)
Solution
Accepted by topic author Ben
09-26-2017 06:46 AM

Re: Programatically obtain strictly typed control reference within TabControl within SubVI


I do not think your reference have to strict they just have to be of the correct type.

 

 


Ah, this was the issue I was having. The problem was because I was creating a "VI Server Class" out of my control. Whenever I would change a tab name or remove a tab it would have issues. I fixed the issue by just creating a manually defined class specifier constant to use in the "to more specific class" object. 

0 Kudos
Message 3 of 9
(132 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI

You don't need to wire your Tab Control reference to the "more specific" VI.  Right click the "To more specific class" target class and create a constant.  Then navigate to the Tab Control under Generic->GObject->Control->PageSelector. 

 

In order for the Controls property node to return an array of all references on the front panel, it has to use a class that is common to all controls and it's up to you to cast them to the specific class in order to get at those properties that are specific to tab controls. 

 

Having said that, why not pass in the tab control reference to this subVI rather than iterating thru all the controls to find it?  You can create a Control Refnum on your front panel and set the class to be Tab Control. 

0 Kudos
Message 4 of 9
(127 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI

Hint:

Spoiler
Ben's post was the solution...not your acknowledgment of his solution.
Give credit where credit is due.  Smiley Wink
Message 5 of 9
(117 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI


aputman wrote:

Hint:

Spoiler
Ben's post was the solution...not your acknowledgment of his solution.
Give credit where credit is due.  Smiley Wink

Maybe you could mark it as solution then?

Message 6 of 9
(67 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI

Hello Wiebe,

I'm sure you know that only OPs can mark a solution.  Before you arrived to the conversation, the OP had marked his own response to Ben's suggestion as the accepted solution but has since removed that.  

Message 7 of 9
(52 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI


aputman wrote:

Hello Wiebe,

I'm sure you know that only OPs can mark a solution.  Before you arrived to the conversation, the OP had marked his own response to Ben's suggestion as the accepted solution but has since removed that.  


Thank you for the concern!

 

While I do not think I have ever marked my own as a solution before today, the Knights of NI can mark solutions.

 

I marked BOTH mine and the reply by the OP. They go together in that I offered the hint and he identified what was the key issue.

 

Again, thank you for baking me up!

 

Ben

0 Kudos
Message 8 of 9
(40 Views)

Re: Programatically obtain strictly typed control reference within TabControl within SubVI


aputman wrote:

Hello Wiebe,

I'm sure you know that only OPs can mark a solution.  Before you arrived to the conversation, the OP had marked his own response to Ben's suggestion as the accepted solution but has since removed that.  


That remark to mark a solution was directed toward OP.

 

Champions can mark solutions as well. I came to read this thread, hoping to help out. Only to find (what I though was) OP's "that is the solution" remark. Wasted 25 valuable seconds (and counting)... It's all good now.

Message 9 of 9
(29 Views)