03-21-2025 05:47 AM
Why is an array of strings classified as an "Array" class in the top method, while in the bottom method it is classified as a "String" class?
03-21-2025 05:52 AM
03-21-2025 05:55 AM
In the top method, you search only the "top-level" controls.
In the bottom method, the search covers all controls, that is, arrays AND the elements they contain.
Think of this as a cluster.
In the top method, you will have only one element: the cluster, the parent.
In the bottom method, you will have the cluster and all the controls it contains, the children.
03-21-2025 07:45 AM
I understand. Is there a way to retrieve only the "top-level" controls in the top method? Additionally, is there a way to determine the order of the references returned by these two methods?
03-21-2025 07:52 AM - edited 03-21-2025 07:53 AM
Hi Max,
@maxnoder1995 wrote:
I understand. Is there a way to retrieve only the "top-level" controls in the top method?
The "top method" returns just the "top level" controls.
(I guess you didn't understand yet.)
@maxnoder1995 wrote:
Additionally, is there a way to determine the order of the references returned by these two methods?
Why do you need the "order" of those references?
You can determine/compare the order by comparing the labels of the referenced fp elements or any other unique property…
(You know you should use unique labels for all fp elements?)
03-21-2025 08:03 AM
@maxnoder1995 wrote:
Why is an array of strings classified as an "Array" class in the top method, while in the bottom method it is classified as a "String" class?
The lower one scans specifically for string objects, the top one shows the top objects, and clearly you have an Array (of strings) as your first object.
The order is typically the Tab order.
03-21-2025 08:28 AM
@maxnoder1995 wrote:
Is there a way to retrieve only the "top-level" controls in the top method?
I guess you meant to ask for the bottom method (with "Traverse for GObjects")?
No because this method goes recursively into data containers such as Clusters and Arrays.
You would have to filter Control references yourself by checking whether their Owner is another Control or not:
@maxnoder1995 wrote:
is there a way to determine the order of the references returned by these two methods?
Panel property "All Objects[]" gives the refnums in the reverse order in which the objects were created.
For "Traverse for GObjects", it is much more complicated. Apparently it also gives refnums in the reverse order of creation, except it goes recursively (depth-first) in the data containers (clusters, arrays, ...), where it also lists the children elements in reverse order of creation, etc...
And finally for TabControls, it also goes recursively into the pages, but in the normal order (Page 1, Page 2, ...).
Regards,
Raphaël.
03-21-2025 08:40 AM
Tab order affects the order of Panel.AllObjs[], but it does not influence the order of the output from "Traverse for GObjects.vi".
It’s also frustrating that there’s no Boolean input for "recursive?"—perhaps this function was designed for a different purpose than what I’m trying to achieve.
Thanks anyway, everyone!
03-21-2025 09:02 AM - edited 03-21-2025 09:32 AM
@maxnoder1995 wrote:
Tab order affects the order of Panel.AllObjs[], but it does not influence the order of the output from "Traverse for GObjects.vi".
Actually, "Panel.AllObjs[]" is not affected by the Tabbing Order, because it also possibly contains decorations, which don't have the tabbing functionality. So the only relevant order is the order of creation, and reversed for some reason. EDIT: actually "Panel.AllObjs[]" follows the Z-order from frontmost to "backmost".
What does match the Tabbing Order is "Panel.Controls[]".
@maxnoder1995 wrote:It’s also frustrating that there’s no Boolean input for "recursive?"
It actually has a flag for that, but it is buried inside the implementation of "Traverse for GObjets". If you look at its diagram, it uses a callback named "TRef FinderCallback.vi", which looks like this:
You could create your own implementation of "Traverse for GObjects" with a custom callback that skips some object's hierarchies based on some condition. However, I would not recommend it because you could encounter more problems than you are trying to currently solve. See this: https://forums.ni.com/t5/LabVIEW/GObject-properties-broken-when-accessed-within-a-Traverse/m-p/38763...
So the post-filtering as I suggested is the best solution to me.
@maxnoder1995 wrote:
perhaps this function [Traverse for GObjects] was designed for a different purpose than what I’m trying to achieve.
I think it is mainly intended for VI Scripting, but can also serve for gathering FP references like it seems you want to do.
Regards,
Raphaël.
03-21-2025 09:27 AM
I’ve written a program that positions each Boolean control directly below a String control on the front panel.
Is this the best approach to do it?