mthheitor Posted October 30, 2018 Report Share Posted October 30, 2018 Hello The attached code will select all boolean from my VI and get the value of each one. Then build a array of boolean that will be used in another VI. My doubt is about the order of the boolean. In my example there four boolean: 1) "Home", 2) "Ensaio", 3) "Análise" and 4) "Configurações". How can I ensure the order of the boolean inside the array? I mean, if a user delete the boolean named "Ensaio" (2nd element of the array) and add another one, it will be the second element of the array or will be last one? Note 1: I'm using this code because the other users will add or remove boolean from the Front Panel, and I don't want them mess around with the block diagram. Note 2: Each boolean is customized, having different images each one. Quote Link to comment
ShaunR Posted October 30, 2018 Report Share Posted October 30, 2018 An indicator has two "labels". The label and caption. Show the caption (should be defaulted to the same as the labe and hide the label). Then rename the controls to 1_Home, 2_Ensaio etc (The caption will be what the user actually sees without the numbers). Now you can get the label name, split off the number and put it into a cluster with the value (if you have less than 10 controls, you don't need to convert to a numeric). Make sure the number is the first item in the cluster because LabVIEW will automatically sort on the first element so you can use the sort array directly. From there you can sort the cluster and now you know your clustered booleans are in numerical order. Quote Link to comment
Francois Normandin Posted October 30, 2018 Report Share Posted October 30, 2018 6 hours ago, mthheitor said: My doubt is about the order of the boolean. In my example there four boolean: 1) "Home", 2) "Ensaio", 3) "Análise" and 4) "Configurações". How can I ensure the order of the boolean inside the array? I mean, if a user delete the boolean named "Ensaio" (2nd element of the array) and add another one, it will be the second element of the array or will be last one? The method you invoke on the Panel reference always returns the Controls in the order that they were created. aka. If you delete the second element and create a new one (even with same label), it will be added to the end of the list. Quote Link to comment
infinitenothing Posted October 31, 2018 Report Share Posted October 31, 2018 (edited) I believe they are in the reference array according to the tab order You either have to know the names in advance or carry their names with their values. Edited October 31, 2018 by infinitenothing Quote Link to comment
Antoine Chalons Posted October 31, 2018 Report Share Posted October 31, 2018 How about using the traverseref.llb? Quote Link to comment
Francois Normandin Posted October 31, 2018 Report Share Posted October 31, 2018 (edited) to the OP: Be mindful that the "Traverse for GObjects" serves the array in the reverse order from Panel:Controls[] method, probably because of the way it stores the references in the recursion loop. @infinitenothing You're totally right. Tab order it is, with newly created controls added at the end of the list. Edited October 31, 2018 by Francois Normandin Quote Link to comment
mthheitor Posted November 27, 2018 Author Report Share Posted November 27, 2018 Thank you all. But I'm using custom Radio Buttons, it solved my problem. @Antoine Chalons didn't know this traverseref.llb. Think I will use it in the future. Thanks. Quote Link to comment
Antoine Chalons Posted November 27, 2018 Report Share Posted November 27, 2018 6 minutes ago, mthheitor said: @Antoine Chalons didn't know this traverseref.llb. Think I will use it in the future. Thanks. You are welcome, this llb is indispensable for scripting and can also help for UI management Quote Link to comment
hooovahh Posted November 27, 2018 Report Share Posted November 27, 2018 So a while ago I wrote a XNode that would add functionality to the traverse for GObjects. One thing it would do is order the references based on their positioning on the front panel or block diagram. The most common use for me was for something like a grid of buttons. I would want them ordered from left to right and top to bottom so I made an enum input to the XNode that orders them after finding them. It would also return the reference as a boolean so no casting was needed after. Of course this goes with the normal "XNodes are experimental" statement but you could look at the code and see how I did it if you wanted to not use it. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.