LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the Reorder Controls property in VI Scripting

Hi everyone, 

So, I have a tab control here, and I want to reorder the controls inside the tab control's page. Normally, we would just Right-click the tab -> Reorder Controls in Page (normal way). But now I would like to try the other way to reorder the controls using the Reorder Controls in Page Method in VI Scripting

. 

BlockDiagram.jpg

FrontPanel.jpg

Initially, the order in page 0 is

  1. Digital
  2. String
  3. Boolean

But now I want it to be

  1. String
  2. Boolean
  3. Digital

I tried the program I designed as attached above. But it wouldn't change the control's order in the specific page of the tab unless I use the normal way. I used the ControlIndex and Class Name of the control to check the order of the control.

 

 

Anyone can help? Thanks a lot!! 😀

0 Kudos
Message 1 of 12
(3,441 Views)

I think the problem is that you are running the VI script on itself.  You need to use a separate VI with the script to act on a non-running VI that has the controls you want to reorder.

 

If you look at the Detailed Help of the Reorder Controls method, then you'll see it says "Settable when the VI is running = NO"

0 Kudos
Message 2 of 12
(3,416 Views)

Hi Benny,

 

Ravens is right!

 

"You need to use a separate VI with the script to act on a non-running VI that has the controls you want to reorder."

 

A bit OOT... try the VI in the snippet below & let me know how it works. For me, it crashed LV2016 at the SaveVI method.

 

Reorder Cluster Controls & Tab Pages.png

 

 

 

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 3 of 12
(3,387 Views)

Thanks for replying and I got the way to change the order. I did it on another VI (Reorder_Tab_Control.vi) using VI scripting and got it worked. For now, I'm just trying to get the idea, so I hard-coded it.

Reorder_tab_Control snippet.png

 

But I still need to go in the tab control and manually right-click->reorder controls first, only then I can reorder the controls in the Reorder_Tab_Control.vi. Is there any way to avoid that, I prefer to reorder the controls in here(Reorder_Tab_Control.vi) without accessing the tab control VI manually. 

Download All
0 Kudos
Message 4 of 12
(3,382 Views)

Hi parthabe,

 

It works fine on LabVIEW 2019, no crash happened.

PageLabel.jpg

But I'm wondering now why I needed to manually reorder tab controls first then only I could reorder using the program (VI attached in my previous comment). Any suggestion or idea to avoid touching the tab control, reorder it using the program instead of manually right-click and reorder it. 

It would be lovely if it is workable. 😀  

0 Kudos
Message 5 of 12
(3,376 Views)

It worked fine for me as is.  Are you sure you needed to "manually" change first?

 

I see an issue with your VI.  You are closing the references to the items in a random order.  You should close the references in the reverse order you opened them.  Also, only your last control is being closed because of the tunnel type (last element vs. indexing).  But that said, it is not always necessary to close references.

 

One other suggestion.  Index Array is expandable by dragging the bottom border.  No need to copy it and split the array wire.

0 Kudos
Message 6 of 12
(3,353 Views)

Could you test my code as it is, because the tab in my snippet has 4 pages, whereas am seeing only 2 in your VI.

 

 

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 7 of 12
(3,329 Views)

Your snippet doesn't have any tab or any specific number of pages.  Yours is just the reordering code.

0 Kudos
Message 8 of 12
(3,310 Views)

Oh I'm sorry! I should have said that the VI that the scripting VI calls, has a Tab control with 4 Pages.

 

 

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 9 of 12
(3,302 Views)

Now it works fine, but I redesigned the code to also change the orders of controls on the 2nd page while remains the 1st-page control's order and it failed. 

Reorder_tab_Control snippet 2.0.png

This is the result:

before

before .jpg

after

after.jpg

What I expect it should be something like this

  1. Numeric (Page 1)
  2. Boolean (Page 1)
  3. String (Page 1)
  4. Array (Page 2)
  5. String 2 (Page 2)
  6. Numeric 2 (Page 2)

In my example here, the controls order will only change on page 1 and page 2 remains. Next, I manually open the Tab Control VI and right-click>Reorder Controls, then I try to run the reorder VI again. Now the changes of the control order made on page 2, and page 1 remains.

 

I believe the problem is the Reorder Controls Method is specified for 1 page. Therefore, when changes made on one page, the previous or other page control's order will be overwritten and stay behind to whatever the order that has been made newly. 

 

Or maybe anyone has a better understanding of the problems stated above.

Download All
0 Kudos
Message 10 of 12
(3,266 Views)