LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't programatically unlock objects on a tab in LV2017

Solved!
Go to solution

I wrote a VI in LV2014 that deletes certain FP objects of a bunch of other VIs, as part of an upgrade tool for other developers on my team. This required first getting a pane reference, then an array of references to objects on the pane, and then unlocking and ungrouping those objects using a Pane VI scripting method, required to allow the delete method to work. This is no longer working in LV2017, and I note that the pane objects do not include controls on a tab (where all my locked objects reside). 

 

Thus, I would like to know how to problematically delete locked and/or grouped objects which appear on a tab.

 

I have tried getting the object references by name, and using those references of the Panel:Unlock method. I have also tried programmatically selecting the objects one by one and using the same method with the object array unwired (which is supposed to unlock the selected object). however, The object does not become selected when I try this).

0 Kudos
Message 1 of 12
(522 Views)

Pretty sure Pane.Controls[] never returned controls on tab control pages.

 

You'll need to recurse over the pages. So:

 

get all controls in my_control[],

 while elements in my_control[] get the first,

  if it's a tab control

   for each page

    add controls to the list

 

You might also want to do this for clusters.

Message 2 of 12
(496 Views)

wiebe@CARYA

 

You'll need to recurse over the pages. So:

 


Recursion is really cool.

Except when you forget what you are doing and try to open the vi on the block diagram, only to realize that this is the vi that you are editing.

Hypothetically speaking, of course Smiley Wink

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 12
(493 Views)

@stevem181 wrote:

wiebe@CARYA

 

You'll need to recurse over the pages. So:

 


Recursion is really cool.

Except when you forget what you are doing and try to open the vi on the block diagram, only to realize that this is the vi that you are editing.

Hypothetically speaking, of course Smiley Wink


Yes, and the old problem: to understand recursion, you fist need to understand recursion.

Message 4 of 12
(491 Views)

In this situation, I wouldn't go for real recursion, but 'fake' recursion.

 

Real recursion, with a VI calling itself doesn't really add value here. I'd make a while loop with an array of references in a shift register. Then take the first element until the array is empty. The first element can be a sub panel, and if it is, add it's controls of all pages to the array. So there is no real recursion, but all controls will be recursed.

0 Kudos
Message 5 of 12
(490 Views)

wiebe@CARYA wrote:

In this situation, I wouldn't go for real recursion, but 'fake' recursion.

 

Real recursion, with a VI calling itself doesn't really add value here. I'd make a while loop with an array of references in a shift register. Then take the first element until the array is empty. The first element can be a sub panel, and if it is, add it's controls of all pages to the array. So there is no real recursion, but all controls will be recursed.


This will work well unless the tab control contains a tab (which might contain a tab...).

Heresy, for sure, but I have "heard" of people that do this kind of thing ...

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 12
(482 Views)
Highlighted

@stevem181 wrote:

wiebe@CARYA wrote:

In this situation, I wouldn't go for real recursion, but 'fake' recursion.

 

Real recursion, with a VI calling itself doesn't really add value here. I'd make a while loop with an array of references in a shift register. Then take the first element until the array is empty. The first element can be a sub panel, and if it is, add it's controls of all pages to the array. So there is no real recursion, but all controls will be recursed.


This will work well unless the tab control contains a tab (which might contain a tab...).

Heresy, for sure, but I have "heard" of people that do this kind of thing ...


It will still work if the tab control has a tab control, that's the point of the recursion.

 

The first tab control will add it's controls to the array. Then later on the tab control that was added will be traversed, and it's controls will be added.

 

Not tested:EDIT Tested:

Fake Recursion.png

Message 7 of 12
(474 Views)

wiebe@CARYA

It will still work if the tab control has a tab control, that's the point of the recursion.

 

The first tab control will add it's controls to the array. Then later on the tab control that was added will be traversed, and it's controls will be added.

 

Not tested:EDIT Tested:


I get it. Good work!

 

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 12
(461 Views)

I suggest using the Traverse for GObjects VI instead of writing your own parsing code.

DNatt, LV R&D
Message 9 of 12
(450 Views)
Solution
Accepted by littlesphaeroid

This is a great little discussion of recursion, and though I thought I'd tried getting references to the objects I needed to unlock, I must have done something wrong yesterday, because on trying again (and using the awesome Traverse GObject VI), I was able to write a general purpose tool to unlock all FP controls (easily modified to work on other object types). I've attached it here. Try it with the demo file included!

0 Kudos
Message 10 of 12
(435 Views)